Friedrich-Alexander-Universität UnivisSuche FAU-Logo
Techn. Fakultät Willkommen am Department Informatik FAU-Logo
Logo I4
Lehrstuhl für Informatik 4
SP2
 
  Vorlesung
     Folien
  Übungen
  Evaluation
  Prüfungsinformationen
  Kontakt
     external linkForum

  protected area Intern
Übungen
  Anmeldung
  Folien
  Aufgaben
Department Informatik  >  Informatik 4  >  Lehre  >  SS 2011  >  SP2  >  Übung  >  Doku  >  extendedprocesslist: plist.h File Reference

process list

plist.h File Reference

Linked List for maintaining process id - command line pairs. More...

#include <sys/types.h>

Go to the source code of this file.

Functions

int insertElement (pid_t pid, const char *commandLine)
 Inserts a new pid-command line pair into the linked list.
int removeElement (pid_t pid, char *commandLineBuffer, size_t bufferSize)
 Remove a specific pid-command line pair from the linked list.
void rewindPList ()
 Reset the list iterator position to the head of the list.
int nextElement (const char **cmdLine, pid_t *pid)
 Provides the next element in the list and advances the list iterator.


Detailed Description

Linked List for maintaining process id - command line pairs.

This implementation is not thread safe.


Function Documentation

int insertElement ( pid_t  pid,
const char *  commandLine 
)

Inserts a new pid-command line pair into the linked list.

During the insert operation, the passed commandLine is copied to an internally allocated buffer. The caller may free or otherwise reuse the memory occupied by commandLine after return from insertElement.

Parameters:
pid The process id of the pair that is to be inserted.
commandLine The commandLine corresponding to the process with id pid.
Returns:
pid on success, negative value on error
Return values:
pid success
-1 a pair with the given pid already exists
-2 insufficient memory to complete the operation

int nextElement ( const char **  cmdLine,
pid_t *  pid 
)

Provides the next element in the list and advances the list iterator.

This functions returns the command line and the pid of the current position of the list iterator, and advances the iterator to the next element afterwards. The function provides a pointer to the internal storage allocated for the commandLine. This storage must not be used after the element was removed using the removeElement function.

Parameters:
cmdLine Pointer to a location, where a pointer to the interal storage location of command line can be written to.
pid Pointer to a location suitable to store a pid value.
Returns:
0 on success, negative value when the iterator has reached the end of the list

int removeElement ( pid_t  pid,
char *  commandLineBuffer,
size_t  bufferSize 
)

Remove a specific pid-command line pair from the linked list.

The linked list is searched for a pair with the given pid. If such a pair is found, the '\0'-terminated command line is copied to the buffer provided by the caller. If the length of the command line exceeds the size of the buffer, only the first (buffersize-1) characters of the command line are copied to the buffer and terminated with the '\0' character. Upon completion, removeElement deallocates all resources that were occupied by the removed pair.

Parameters:
pid The process id of the pair that is to be removed.
commandLineBuffer A buffer provided by the caller that the '\0'-terminated commandline is written to.
bufferSize The size of commandLineBuffer.
Returns:
actual length of the command line on success, negative value on error.
Return values:
>0 success, actual length of the command line
-1 a pair with the given pid does not exist

void rewindPList (  ) 

Reset the list iterator position to the head of the list.

This function should be invoked before starting a list traversal with the nextElement() function. The internal position of the list iterator is reset to the head of the list.

  Impressum   Datenschutz Stand: 2011-04-15 13:27   MS