The "cm" Package
These routines are meant to provide a generic and simple to use child
process management facility.
A similar set of routines: chx_ provide identical functionality
(with the exception of the polling routine), except that they rely on the
Xt Intrinsics.
Library: karma
Link With: -lkarma
Functions
cm_manage | Register a function to manage a child process.
|
cm_unmanage | Terminate the management of a child process for state changes.
|
cm_poll | Poll for child process state changes.
|
cm_poll_silent | Poll for child process state changes.
|
Prototype Functions
Functions
flag
cm_manage ( int pid, void (*stop_func) (), void (*term_func) (),
void (*exit_func) () )
This routine will manage a child process for state changes by
registering callback routines.
Parameters:
- pid :
The child process ID to manage.
- stop_func :
This routine is called when the child is stopped (by a SIGTTIN,
SIGTTOU, SIGTSTP, or SIGSTOP signal). If this is NULL, no callback routine
is installed. The prototype function is cm_PROTO_stop_func
- term_func :
This routine is called when the child terminates due to a
signal. If this is NULL, no callback routine is installed. The prototype
function is cm_PROTO_term_func.
- exit_func :
This routine is called when the child exits due to a call to
_exit. If this is NULL, no callback routine is installed. The prototype
function is cm_PROTO_exit_func.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note: - If a child process is killed or exits, its callback routines are
automatically removed. The term_func or exit_func MUST NOT unmanage
the child process.
void
cm_unmanage (int pid)
Terminate the management of a child process for state changes.
Parameters:
- pid :
The ID of the child process to unmanage.
Returns: Nothing.
Multithreading Level: Unsafe
void
cm_poll (flag block)
This routine will poll for any change in status of child
processes. If the operating system does not support forking, the routine
displays an error message. Those processes which have been registered using
cm_manage will have any callback routines called. If a child has not
been registered using cm_manage then the routine will print a warning
message stating that the child was not managed.
Parameters:
- block :
If TRUE, the routine will poll forever until a child changes status
or a signal is caught.
Returns: Nothing.
Multithreading Level: Unsafe
Note: - If the process has no children, the routine will ALWAYS return
immediately.
void
cm_poll_silent (flag block)
This routine will poll for any change in status of child
processes. If the operating system does not support forking, the routine
does not display an error message (unlike cm_poll. Those processes
which have been registered using cm_manage will have any callback
routines called. If a child has not been registered using cm_manage
then the routine will print a warning message stating that the child was
not managed.
Parameters:
- block :
If TRUE, the routine will poll forever until a child changes status
or a signal is caught.
Returns: Nothing.
Multithreading Level: Unsafe
Note: - If the process has no children, the routine will ALWAYS return
immediately.
Prototype Functions
void
cm_PROTO_stop_func (int pid, int sig)
This routine is called when a child process is stopped.
Parameters:
- pid :
The process ID.
- sig :
The signal which stopped the process.
Returns: Nothing.
Multithreading Level: Unsafe
void
cm_PROTO_term_func (int pid, int sig, struct rusage *rusage)
This routine is called when a child process is killed.
Parameters:
- pid :
The process ID.
- sig :
The signal which killed the process.
- rusage :
The resource usage information. If this is NULL, the platform does
not support this.
Returns: Nothing.
Multithreading Level: Unsafe
void
cm_PROTO_exit_func (int pid, int value, struct rusage *rusage)
This routine is called when a child process exits.
Parameters:
- pid :
The process ID.
- value :
The value passed to _exit.
- rusage :
The resource usage information. If this is NULL, the platform does
not support this.
Returns: Nothing.
Multithreading Level: Unsafe
Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services