libsysactivity 0.6.2
Data Structures | Enumerations | Functions
Process interface

Data Structures

struct  sa_process_activity
struct  sa_process

Enumerations

enum  sa_process_state {
  SA_UNKNOWN = 0, SA_RUNNING = 1, SA_SLEEPING = 2, SA_SLEEPING_UNINTERRUPTIBLE = 3,
  SA_ZOMBIE = 4, SA_STOPPED = 5
}

Functions

int sa_open_process () SA_EXPORT
int sa_close_process () SA_EXPORT
int sa_count_processes (uint32_t *number) SA_EXPORT SA_NONNULL
int sa_get_processes_ids (pid_t *dst, uint32_t dst_size, uint32_t *written) SA_EXPORT SA_NONNULL
int sa_get_process (pid_t pid, struct sa_process *dst) SA_EXPORT SA_NONNULL
int sa_get_process_activity (pid_t pid, struct sa_process_activity *dst) SA_EXPORT SA_NONNULL

Enumeration Type Documentation

The different types of states of a process.

Enumerator:
SA_UNKNOWN 

The state is unknown.

SA_RUNNING 

The process is running.

SA_SLEEPING 

The process is sleeping.

SA_SLEEPING_UNINTERRUPTIBLE 

The process is an uninterruptible sleep.

SA_ZOMBIE 

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

SA_STOPPED 

The process is traced or stopped.


Function Documentation

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 operating system is not supported the return value will be ENOTSUP.
See also:
sa_close_process()
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()
int sa_count_processes ( uint32_t *  number)

Gives the total number of processes on the systems.

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

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

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

Retrieves statistics from a process identified by its pid.

Parameters:
pidThe pid of the process.
dstWhere the statistics will be stored.
Returns:
If successful 0 is returned, otherwise an error code is returned. ESRCH is returned if the requested process was not found.
int sa_get_process_activity ( pid_t  pid,
struct sa_process_activity dst 
)

Retrieves the activity of a process on the dst parameter.

Parameters:
pidThe pid of the process.
dstWhere the statistics will be stored.
Returns:
If successful 0 is returned, otherwise an error code is returned. ESRCH is returned if the requested process was not found.
Since:
0.6.0
 All Data Structures Variables