Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

process.h File Reference

Basic operations on processes. More...

Go to the source code of this file.

Defines

Enumerations

Functions


Detailed Description

Basic operations on processes.

A process, its status and its environment are defined by a ProcessData structure. The functions in this module can start and stop processes described by that structure.


Enumeration Type Documentation

enum ProcessState
 

Actual Process State.

Enumeration values:
PROCESS_STATE_OFF  Process is not running.
PROCESS_STATE_ON  Process is running.
PROCESS_STATE_ERR  Process could not be started successfully.
PROCESS_STATE_WAIT  Process is currently being started.

enum RequiredState
 

Required state of a process.

Enumeration values:
PROCESS_ACTIVE  Process should be running.
PROCESS_STANDBY  Process should not be running.

enum RestartPolicy
 

Restart policy when a process has died.

Enumeration values:
PROCESS_RESTART_YES  Restart this process.
PROCESS_RESTART_NO  Ignore, don't restart.
PROCESS_RESTART_ALL  Restart all processes.


Function Documentation

void process_add_environment ProcessData proc,
const char *  attr,
const char *  value
 

Adds an environment variable to the process data.

Parameters:
proc Process data.
attr Variable name.
value Value.

ProcessData* process_array_find_by_pid Array array,
int  pid
 

Fiends a process entry by PID.

Parameters:
array A process array
pid The process ID to look for
Returns:
A pointer to a ProcessData structure or NULL if no matching entry was found.

ProcessData* process_array_find_by_tag Array array,
const char *  tag
 

Fiends a process entry by tag.

Parameters:
array A process array
tag The process tag to look for
Returns:
A pointer to a ProcessData structure or NULL if no such matching entry was found.

void process_decrement_failure_timer ProcessData proc  ) 
 

Decrements the failure timer.

Parameters:
proc Process data
This function decrements the failure timer. If the timer reaches 0, the counter of subsequent failures is also set to 0.

If a process crashes, the process control tries to restart it. If a situation occurs where a process gets restarted over and over again, the process control needs a criterion to detect this as an error and give up restarting the process. This works with a failure counter and a failure timer. Withe every restart of a process, its failure timer is set to an initial value, and its counter of subsequent failures is incremented. With every update interval, the failure timer is decremented. When the failure timer reaches 0, the counter of subsequent failures is also set to 0. When the counter of subsequent failures reaches a maximal value before the failure timer reaches zero, then the process will not be restarted again.

void process_destroy void *  data  ) 
 

Destroys a ProcessData structure and all its contents.

Parameters:
data Pointer to a ProcessData structure.

int process_exists ProcessData proc  ) 
 

Checks if a process exists.

Parameters:
proc Process data.
Returns:
1 if the process exists

int process_has_max_subsequent_failures ProcessData proc  ) 
 

Returns true if the number of subsequent failures has reacehd its maximum.

Parameters:
proc Process data

int process_kill ProcessData proc  ) 
 

Kill a process.

Parameters:
proc Process data.

void process_notify_failure ProcessData proc  ) 
 

Registers a failure.

This function has to be called when a process is to be restarted automatically. It increments the total failure couter. It increments the subsequent feilure couter if the failure timer is > 0;

void process_notify_start ProcessData proc  ) 
 

Registers a process start.

This function is called by process_start.

void process_notify_truncation ProcessData proc  ) 
 

Registers a process truncation.

Parameters:
proc Process data
This function has to be called whenever a process has been stopped automatically.

void process_reset_failures ProcessData proc  ) 
 

Resets the failure counter.

Parameters:
proc Process data.
This function has to be called whenever a process is started intentionally. It resets the failure counter which limits the number of automatic restarts.

See also:
process_decrement_failure_timer()

void process_reset_statistics ProcessData proc  ) 
 

Resets the process statistics.

Parameters:
proc Process data.

void process_set_attribute ProcessData proc,
const char *  attr,
const char *  value
 

Sets an attribute.

Parameters:
proc Pointer to Process data
attr Attribute's name
value Attribute's value

int process_shutdown ProcessData proc  ) 
 

Stops a process.

Parameters:
proc Process data.
Behaves like process_stop(), but uses the delay time as configured in proc->term_delay_ms .

int process_start ProcessData proc,
int  execInitScript
 

Starts a process.

Parameters:
proc Process data
execInitScript If true, execute an initialization script before starting the process.
Returns:
PID of the started process, or 0 if not successful.
This function does not check if the specified process already exists.

int process_stop ProcessData proc,
int  waitTimeMs
 

Stops a process.

Parameters:
proc Process data.
msec_wait Wait time between TERM and KILL signal.
This function sends a TERM signal to a process, waits for a specified time, checks if the process has terminated, and sends a KILL signal if the process still exists.

int process_terminate ProcessData proc  ) 
 

Sends a TERM signal to a process.

Parameters:
proc Process data.


Generated on Fri Jan 20 10:12:18 2006 by  doxygen 1.4.2