| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- wait for child process to change state
#include <sys/types.h>#include <sys/wait.h>pid_twaitpid(pid_tpid,int *stat_loc,intoptions);
Thewaitpid() function will suspend execution of the calling thread until statusinformation for one of its terminated child processes is available, or untildelivery of a signal whose action is either to execute a signal-catchingfunction or to terminate the process. If more than one thread is suspendedinwaitpid(),wait(3C), orwaitid(2) awaiting termination of the same process, exactlyone thread will return the process status at the time of thetarget process termination. If status information is available prior to the calltowaitpid(), return will be immediate.
Thepid argument specifies a set of child processes for which statusis requested, as follows:
Ifpid is less than(pid_t)-1, status is requested for any child process whose process group ID is equal to the absolute value ofpid.
Ifpid is equal to(pid_t)-1, status is requested for any child process.
Ifpid is equal to(pid_t)0 status is requested for any child process whose process group ID is equal to that of the calling process.
Ifpid is greater than(pid_t)0, it specifies the process ID of the child process for which status is requested.
One instance of aSIGCHLD signal is queued for each child processwhose status has changed. Ifwaitpid() returns because the status of achild process is available, andWNOWAIT was not specified inoptions, any pendingSIGCHLD signal associated with the process ID of that child process isdiscarded. Any other pendingSIGCHLD signals remain pending.
If the calling process hasSA_NOCLDWAIT set or hasSIGCHLD set toSIG_IGN and the process has no unwaited children that were transformed intozombie processes, it will block until all of its children terminate, andwaitpid() will fail and seterrno toECHILD.
Ifwaitpid() returns because the status of a child process is available,then that status may be evaluated with the macros defined bywait.h(3HEAD) If the calling process had specified a non-zero value ofstat_loc,the status of the child process will be stored in the locationpointed to bystat_loc.
Theoptions argument is constructed from the bitwise-inclusive OR of zero ormore of the following flags, defined in the header <sys/wait.h>:
The status of any continued child process specified bypid, whose status has not been reported since it continued, is also reported to the calling process.
Thewaitpid() function will not suspend execution of the calling process if status is not immediately available for one of the child processes specified bypid.
Keep the process whose status is returned instat_loc in a waitable state. The process may be waited for again with identical results.
The status of any child processes specified bypid that are stopped, and whose status has not yet been reported since they stopped, is also reported to the calling process.WSTOPPED is a synonym forWUNTRACED.
Ifwaitpid() returns because the status of a child process is available, it returns a value equal to the process ID of thechild process for which status is reported. Ifwaitpid() returns dueto the delivery of a signal to the calling process,-1 is returnedanderrno is set toEINTR. Ifwaitpid() was invoked withWNOHANG set inoptions, it has at least one child processspecified bypid for which status is not available, and status is notavailable for any process specified bypid, then0 is returned. Otherwise,-1 is returned anderrno is set to indicate the error.
Thewaitpid() function will fail if:
The process or process group specified bypid does not exist or is not a child of the calling process or can never be in the states specified byoptions.
Thewaitpid() function was interrupted due to the receipt of a signal sent by the calling process.
An invalid value was specified foroptions.
Withoptions equal to0 andpid equal to(pid_t)-1,waitpid()is identical towait(3C). Thewaitpid() function is implemented as a callto the more generalwaitid(2) function.
Seeattributes(5) for descriptions of the following attributes:
|
Intro(2),exec(2),exit(2),fork(2),pause(2),sigaction(2),ptrace(3C),signal(3C),siginfo.h(3HEAD),wait(3C),wait.h(3HEAD),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |