cctools
Data Structures | Functions
process.h File Reference

Provides a higher level interface to finding information about complete processes. More...

#include <sys/time.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/wait.h>

Go to the source code of this file.

Data Structures

struct  process_info
 Describes a completed process. More...
 

Functions

struct process_infoprocess_wait (int timeout)
 Wait for a process to complete, and return its status. More...
 
struct process_infoprocess_waitpid (pid_t pid, int timeout)
 Wait for a specific process to complete and return its status. More...
 
int process_pending ()
 Detect if a child process has completed. More...
 
void process_putback (struct process_info *p)
 Return a process_info structure to the queue. More...
 

Detailed Description

Provides a higher level interface to finding information about complete processes.

Useful as a replacement for wait, waitpid and similar calls, which do not allow the caller to check for completion without permanently removing the completion notice.

Call process_pending to see if there is a recently completed process, process_wait to wait for completion with a timeout, and process_putback to put the completion back into the queue.

Function Documentation

struct process_info* process_wait ( int  timeout)

Wait for a process to complete, and return its status.

Wait for up to timeout seconds for a child process to complete. If a process has completed, its status will be returned in a process_info structure. The caller may either call free to release the structure, or may return it via process_putback in order to allow another caller to retrieve it.

Parameters
timeoutThe time, in seconds to wait for a child to complete. If zero, do not wait at all.
Returns
A process_info structure describing the child process status, or null if no process completed in the available time.
struct process_info* process_waitpid ( pid_t  pid,
int  timeout 
)

Wait for a specific process to complete and return its status.

Like process_wait, but waits for a specific pid.

int process_pending ( )

Detect if a child process has completed.

If so, its status may be obtained without delay by calling process_wait .

Returns
True if a child process has completed.
void process_putback ( struct process_info p)

Return a process_info structure to the queue.

Parameters
pA process_info structure returned by process_wait.