Data Structures | Enumerations | Functions

Process interface

Data Structures

struct  sa_process

Enumerations

enum  sa_process_state {
  RUNNING = 0, SLEEPING = 1, SLEEPING_UNINTERRUPTIBLE = 2, ZOMBIE = 3,
  STOPPED = 4
}

Functions

SA_EXPORT int sa_open_process ()
SA_EXPORT int sa_close_process ()
SA_EXPORT int sa_count_processes (pid_t *number)
SA_EXPORT int sa_get_processes_ids (pid_t *dst, pid_t dst_size, pid_t *written)
SA_EXPORT int sa_get_process (pid_t pid, struct sa_process *dst)
SA_EXPORT int sa_get_processes (struct sa_process *dst, pid_t dst_size, pid_t *written)

Enumeration Type Documentation

The different types of states of a process.

Enumerator:
RUNNING 

The process is running.

SLEEPING 

The process is sleeping.

SLEEPING_UNINTERRUPTIBLE 

The process is an uninterruptible sleep.

ZOMBIE 

It has completed execution but still has an entry in the process table.

STOPPED 

The process is traced or stopped.


Function Documentation

SA_EXPORT int sa_open_process (  ) 

Prepares the resources needed for retrieving process statistics. This function exists (and is needed) only when SA_OPEN_PROCESS is defined.

Returns:
If successful 0 is returned, otherwise an error code is returned. If the operative system is not supported the return value will be ENOTSUP.
See also:
sa_close_process()
SA_EXPORT int sa_close_process (  ) 

This function closes the resources used for retrieving process statistics. You should call it even when there was a previous error in another function of this API. This function exists (and is needed) only when SA_CLOSE_PROCESS is defined.

Returns:
If successful 0 is returned, otherwise an error code is returned.
See also:
sa_open_process()
SA_EXPORT int sa_count_processes ( pid_t *  number  ) 

Gives the total number of processes on the systems.

Parameters:
number The number will be stored here
Returns:
If successful 0 is returned, otherwise an error code is returned.
SA_EXPORT int sa_get_processes_ids ( pid_t *  dst,
pid_t  dst_size,
pid_t *  written 
)

Gets a list of the current processes ids in the system. The array will be fully populated even if it's not big enough (but ENOMEM is returned).

Parameters:
dst A pointer to the array to populate.
dst_size The number of pid_t that fits in the array.
written The amount of pids written is stored here.
Returns:
If successful 0 is returned, otherwise an error code is returned.
Since:
0.4.1
SA_EXPORT int sa_get_process ( pid_t  pid,
struct sa_process dst 
)

Retrieves statistics from a process identified by its pid.

Parameters:
pid The pid of the process.
dst Where the statistics will be stored.
Returns:
If successful 0 is returned, otherwise an error code is returned. ESRCH is returned when the requested process was not found.
SA_EXPORT int sa_get_processes ( struct sa_process dst,
pid_t  dst_size,
pid_t *  written 
)

Retrieves statistics about all the processes on the system.

Parameters:
dst A buffer where the statistics will be stored.
dst_size The number of process that fits in the dst buffer. If it's not big enough dst will be filled but ENOMEM will be returned.
written The amount of processes written.
Returns:
If successful 0 is returned, otherwise an error code is returned.
 All Data Structures Variables