Process Control Routines

Process control routines control the operation of a process or subprocess. You can wait for a subprocess to complete with either SLEEP or ALARM, monitor its progress and send signals via KILL, and stop its execution with ABORT.

In spite of its name, KILL does not necessarily stop execution of a program. Rather, the routine signaled could include a handler routine that examines the signal and takes appropriate action depending on the code passed.

Portability Routine Description
ABORT Stops execution of the current process, clears I/O buffers, and writes a string to external unit 0
ALARM Executes an external subroutine after waiting a specified number of seconds
KILL Sends a signal code to a process ID
SIGNAL Changes the action for a signal
SLEEP Suspends program execution for a specified number of seconds
SYSTEM Executes a command in a separate shell

Note that when you use SYSTEM, commands are run in a separate shell. Defaults set with the SYSTEM function, such as current working directory or environment variables, do not affect the environment the calling program runs in.

The portability library does not include the FORK routine. On U*X systems, FORK creates a duplicate image of the parent process. Child and parent processes each have their own copies of resources, and become independent from one another. With Windows operating systems, you can create a child process (called a thread), but both parent and child processes share the same address space and share system resources. If you need to create another process, use the CreateProcess Win32 API routine.

For information on how to implement threading, see Creating Multithread Applications.