Header File
process.h
Category
Process Control Routines
Prototype
int wait(int *statloc);
Description
Waits for one or more child processes to terminate.
The wait function waits for one or more child processes to terminate. The child processes must be those created by the calling program; wait cannot wait for grandchildren (processes spawned by child processes). If statloc is not NULL, it points to location where wait will store the termination status.
If the child process terminated normally (by calling exit, or returning from main), the termination status word is defined as follows:
Bits 0-7 |
Zero. |
Bits 8-15 |
The least significant byte of the return code from the child process. This is the value that is passed to exit, or is returned from main. If the child process simply exited from main without returning a value, this value will be unpredictable. If the child process terminated abnormally, the termination status word is defined as follows: |
Bits 0-7 |
Termination information about the child: |
Bits 8-15 |
Zero. |
Return Value
When wait returns after a normal child process termination it returns the process ID of the child.
When wait returns after an abnormal child termination it returns -1 to the parent and sets errno to EINTR.
If wait returns without a child process completion it returns a -1 value and sets errno to:
ECHILD |
No child process exists |
Portability
POSIX |
Win32 |
ANSI C |
ANSI C++ |
|
+ |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|