View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000690 | 1003.1(2013)/Issue7+TC1 | System Interfaces | public | 2013-05-07 06:18 | 2019-06-10 08:55 |
Reporter | tedu | Assigned To | |||
Priority | normal | Severity | Editorial | Type | Clarification Requested |
Status | Closed | Resolution | Accepted As Marked | ||
Name | Ted Unangst | ||||
Organization | OpenBSD | ||||
User Reference | |||||
Section | XSH 2.4.3, _Exit(), sigaction(), wait(), waitpid(), waitid(), wait() | ||||
Page Number | 491, 549-550, 1932, 2203, 2212 | ||||
Line Number | 16773-16779, 19051-19072, 61931-61938, 69847-69856, 69881-69884, 70244-70250 | ||||
Interp Status | Approved | ||||
Final Accepted Text | 0000690:0001625 | ||||
Summary | 0000690: clarify behavior when calling waitpid with SA_NOCLDWAIT | ||||
Description | From the description for waitpid: If the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, and the process has no unwaited-for children that were transformed into zombie processes, the calling thread shall block until all of the children of the process containing the calling thread terminate, and wait() and waitpid() shall fail and set errno to [ECHILD]. Similar text also appears in 2.4.3 Signal Actions of the base definitions. The description for waitid (no p) doesn't indicate what its behavior is at all. Please clarify the interaction when waitpid is called with a pid parameter that matches no children. As specified, I believe a strict interpretation requires the calling thread to block even when calling waitpid with an invalid pid. A more desirable interpretation might allow waitpid to return immediately if the pid doesn't exist or is not a child. See attached source file. | ||||
Desired Action | "In the case of waitpid, the calling thread shall block until no children match the pid parameter." ? | ||||
Tags | tc2-2008 | ||||
Attached Files |
has duplicate | 0000788 | Closed | 1003.1(2013)/Issue7+TC1 | Definition of Zombie Process unclear | |
related to | 0000594 | Closed | ajosey | 1003.1(2008)/Issue 7 | Clarify interaction of si_status and WIF* macros |
related to | 0000792 | Closed | 1003.1(2013)/Issue7+TC1 | better definition of thread lifetime | |
related to | 0000947 | Closed | ajosey | 1003.1(2008)/Issue 7 | Shell should not have $? == 0 for exit(256) |
related to | 0000959 | Closed | ajosey | 1003.1(2008)/Issue 7 | struct siginfo member si_pid is marked "CX" but is mandatory for the non-CX waitid() |
|
The interaction with WCONTINUED and WUNTRACED is also missing: waitpid() will return successfully if a child matches those conditions and the pid argument. Hmm, I guess those are affected by SA_NOCLDSTOP though. Also: waitid() currently lacks any reference to SA_NOCLDWAIT, despite following the same rules as wait() and waitpid() on at least Solaris 10 and Linux 2.6.18. |
|
Proposed changes: After Issue7+TC1 XBD section 3.209 ("Link Count") page 66 line 1935, insert a new section 3.210 Live Process whose contents are copied from Issue7+TC1 XBD section 3.291 ("Process") page 80 lines 2269-2275 and renumber the subsequent sections. At Issue7+TC1 XBD section 3.291 ("Process") page 80 lines 2269-2275, change: An address space with one or more threads executing within that address space, and the required system resources for those threads.to: A live process (see Section 3.210) or a zombie process (see Section 3.447). The lifetime of a process is described in Section 3.298.Note that the new text uses the adjusted section numbers. At Issue7+TC1 XBD section 3.297 ("Process Lifetime") page 81 lines 2295-2304, change: The period of time that begins when a process is created and ends when its process ID is returned to the system. After a process is created by fork(), posix_spawn(), or posix_spawnp(), it is considered active. At least one thread of control and address space exist until it terminates. It then enters an inactive state where certain resources may be returned to the system, although some resources, such as the process ID, are still in use. When another process executes a wait(), waitid(), or waitpid() function for an inactive process, the remaining resources are returned to the system. The last resource to be returned to the system is the process ID. At this time, the lifetime of the process ends.to: The period of time that begins when a process is created and ends when its process ID is returned to the system.Note that the new text uses the adjusted section numbers. At Issue7+TC1 XBD section 3.299 ("Process Termination") page 81 lines 2318-2319, change: <small>Note: The _exit(), _Exit(), abort(), and exit() functions are defined in detail in the System Interfaces volume of POSIX.1-2008.</small>to: <small>Note: The consequences of process termination can be found in the description of the _Exit() function in the System Interfaces volume of POSIX.1-2008. The _exit(), _Exit(), abort(), and exit() functions are defined in detail in the System Interfaces volume of POSIX.1-2008.</small>At Issue7+TC1 XBD section 3.446 ("Zombie Process") page 105 lines 2871-2872, change: A process that has terminated and that is deleted when its exit status has been reported to another process which is waiting for that process to terminate.to: The remains of a live process (see Section 3.210) after it terminates (see Section 3.300) and before its status information (see XSH Section 2.13) is consumed by its parent process.Note that the new text uses the adjusted section numbers. After Issue7+TC1 XSH section 2.12 page 546 line 19012, insert: 2.13 Status Informationand renumber the subsequent sections. At Issue7+TC1 XBD chapter 13 <signal.h> page 334 line 11158, change: [CX]SA_NOCLDWAIT Causes implementations not to create zombie processes on child death.[/CX]to: [XSI]SA_NOCLDWAIT Causes implementations not to create zombie processes or status information on child termination. See sigaction(), page 1932.[/XSI]Note the change from CX shading to XSI shading. At Issue7+TC1 XSH section 2.4.3 page 491 lines 16773-16779, change: If a process sets the action for the SIGCHLD signal to SIG_IGN, the behavior is unspecified, [XSI]except as specified below.to: If a process sets the action for the SIGCHLD signal to SIG_IGN, the behavior is unspecified[XSI], except as specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549[/XSI].At Issue7+TC1 XSH chapter 3 (description of _Exit() and _exit(), "Consequences of Process Termination") pages 549-550 lines 19051-19072, after applying the changes in 0000594, change: to: At Issue7+TC1 XSH chapter 3 sigaction() description page 1932 lines 61931-61938, change: SA_NOCLDWAIT: If set, and sig equals SIGCHLD, child processes of the calling processes shall not be transformed into zombie processes when they terminate. If the calling process subsequently waits for its children, and the process has no unwaited-for children that were transformed into zombie processes, it shall block until all of its children terminate, and wait(), waitid(), and waitpid() shall fail and set errno to [ECHILD]. Otherwise, terminating child processes shall be transformed into zombie processes, unless SIGCHLD is set to SIG_IGN.to: [XSI]SA_NOCLDWAIT: If sig does not equal SIGCHLD, the behavior is unspecified. Otherwise, the behavior of the SA_NOCLDWAIT flag is as specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549.[/XSI]Note the addition of XSI shading, which I believe was an omission. At Issue7+TC1 XSH chapter 3 wait() and waitpid() description page 2203 lines 69847-69856, change: The wait() and waitpid() functions shall obtain status information pertaining to one of the caller's child processes. Various options permit status information to be obtained for child processes that have terminated or stopped. If status information is available for two or more child processes, the order in which their status is reported is unspecified.to: The wait() and waitpid() functions shall obtain status information (see XSH Section 2.13) pertaining to one of the caller's child processes. The wait() function obtains status information for process termination from any child process. The waitpid() function obtains status information for process termination, and optionally process stop and/or continue, from a specified subset of the child processes.At Issue7+TC1 XSH chapter 3 wait() and waitpid() description page 2203 lines 69881-69884, remove: [XSI]If the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, and the process has no unwaited-for children that were transformed into zombie processes, the calling thread shall block until all of the children of the process containing the calling thread terminate, and wait() and waitpid() shall fail and set errno to [ECHILD].[/XSI]After Issue7+TC1 XSH chapter 3 wait() and waitpid() application usage page 2208 after line 70110, insert: [XSI]As specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549, if the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, then the termination of a child process will not cause status information to become available to a thread blocked in wait(), waitid(), or waitpid(). Thus, a thread blocked in one of the wait functions will remain blocked unless some other condition causes the thread to resume execution (such as an [ECHILD] failure due to no remaining children in the set of waited-for children).[/XSI]At Issue7+TC1 XSH chapter 3 waitid() description page 2212 lines 70244-70250, change: The waitid() function shall suspend the calling thread until one child of the process containing the calling thread changes state. It records the current state of a child in the structure pointed to by infop. The fields of the structure pointed to by infop are filled in as described for the SIGCHLD signal in <signal.h>. If a child process changed state prior to the call to waitid(), waitid() shall return immediately. If more than one thread is suspended in wait(), waitid(), or waitpid() waiting for termination of the same process, exactly one thread shall return the process status at the time of the target process termination.to: The waitid() function shall obtain status information (see XSH Section 2.13) pertaining to termination, stop, and/or continue events in one of the caller's child processes.After Issue7+TC1 XSH chapter 3 waitpid() application usage at page 2213 line 70293, insert: [XSI]As specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549, if the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, then the termination of a child process will not cause status information to become available to a thread blocked in wait(), waitid(), or waitpid(). Thus, a thread blocked in one of the wait functions will remain blocked unless some other condition causes the thread to resume execution (such as an [ECHILD] failure due to no remaining children in the set of waited-for children).[/XSI] |
|
Interpretation response ------------------------ The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor. Rationale: ------------- None. Notes to the Editor (not part of this interpretation): ------------------------------------------------------- Make the changes in 0000690:0001855. |
|
Interpretation Proposed 6 Sep 2013 |
|
Changes were suggested during the original review period (see <http://thread.gmane.org/gmane.comp.standards.posix.austin.general/8095 >). The following are the new proposed changes, meant to supersede 0000690:0001602: After Issue7+TC1 XBD section 3.209 ("Link Count") page 66 line 1935, insert a new section 3.210 Live Process whose contents are copied from Issue7+TC1 XBD section 3.291 ("Process") page 80 lines 2269-2275 and renumber the subsequent sections. At Issue7+TC1 XBD section 3.291 ("Process") page 80 lines 2269-2275, change: An address space with one or more threads executing within that address space, and the required system resources for those threads.to: A live process (see Section 3.210) or a zombie process (see Section 3.447). The lifetime of a process is described in Section 3.298.Note that the new text uses the adjusted section numbers. At Issue7+TC1 XBD section 3.297 ("Process Lifetime") page 81 lines 2295-2304, change: The period of time that begins when a process is created and ends when its process ID is returned to the system. After a process is created by fork(), posix_spawn(), or posix_spawnp(), it is considered active. At least one thread of control and address space exist until it terminates. It then enters an inactive state where certain resources may be returned to the system, although some resources, such as the process ID, are still in use. When another process executes a wait(), waitid(), or waitpid() function for an inactive process, the remaining resources are returned to the system. The last resource to be returned to the system is the process ID. At this time, the lifetime of the process ends.to: The period of time that begins when a process is created and ends when its process ID is returned to the system.Note that the new text uses the adjusted section numbers. At Issue7+TC1 XBD section 3.299 ("Process Termination") page 81 lines 2318-2319, change: <small>Note: The _exit(), _Exit(), abort(), and exit() functions are defined in detail in the System Interfaces volume of POSIX.1-2008.</small>to: <small>Note: The consequences of process termination can be found in the description of the _Exit() function in the System Interfaces volume of POSIX.1-2008. The _exit(), _Exit(), abort(), and exit() functions are defined in detail in the System Interfaces volume of POSIX.1-2008.</small>At Issue7+TC1 XBD section 3.446 ("Zombie Process") page 105 lines 2871-2872, change: A process that has terminated and that is deleted when its exit status has been reported to another process which is waiting for that process to terminate.to: The remains of a live process (see Section 3.210) after it terminates (see Section 3.300) and before its status information (see XSH Section 2.13) is consumed by its parent process.Note that the new text uses the adjusted section numbers. After Issue7+TC1 XSH section 2.12 page 546 line 19012, insert: 2.13 Status Informationand renumber the subsequent sections. At Issue7+TC1 XBD chapter 13 <signal.h> page 334 line 11158, change: [CX]SA_NOCLDWAIT Causes implementations not to create zombie processes on child death.[/CX]to: [XSI]SA_NOCLDWAIT Causes implementations not to create zombie processes or status information on child termination. See sigaction(), page 1932.[/XSI]Note the change from CX shading to XSI shading. At Issue7+TC1 XSH section 2.4.3 page 491 lines 16773-16779, change: If a process sets the action for the SIGCHLD signal to SIG_IGN, the behavior is unspecified, [XSI]except as specified below.to: If a process sets the action for the SIGCHLD signal to SIG_IGN, the behavior is unspecified[XSI], except as specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549[/XSI].At Issue7+TC1 XSH chapter 3 (description of _Exit() and _exit(), "Consequences of Process Termination") pages 549-550 lines 19051-19072, after applying the changes in 0000594, change: to: At Issue7+TC1 XSH chapter 3 sigaction() description page 1932 lines 61931-61938, change: SA_NOCLDWAIT: If set, and sig equals SIGCHLD, child processes of the calling processes shall not be transformed into zombie processes when they terminate. If the calling process subsequently waits for its children, and the process has no unwaited-for children that were transformed into zombie processes, it shall block until all of its children terminate, and wait(), waitid(), and waitpid() shall fail and set errno to [ECHILD]. Otherwise, terminating child processes shall be transformed into zombie processes, unless SIGCHLD is set to SIG_IGN.to: [XSI]SA_NOCLDWAIT: If sig does not equal SIGCHLD, the behavior is unspecified. Otherwise, the behavior of the SA_NOCLDWAIT flag is as specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549.[/XSI]Note the addition of XSI shading, which I believe was an omission. At Issue7+TC1 XSH chapter 3 wait() and waitpid() description page 2203 lines 69847-69856, change: The wait() and waitpid() functions shall obtain status information pertaining to one of the caller's child processes. Various options permit status information to be obtained for child processes that have terminated or stopped. If status information is available for two or more child processes, the order in which their status is reported is unspecified.to: The wait() and waitpid() functions shall obtain status information (see XSH Section 2.13) pertaining to one of the caller's child processes. The wait() function obtains status information for process termination from any child process. The waitpid() function obtains status information for process termination, and optionally process stop and/or continue, from a specified subset of the child processes.At Issue7+TC1 XSH chapter 3 wait() and waitpid() description page 2203 lines 69881-69884, remove: [XSI]If the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, and the process has no unwaited-for children that were transformed into zombie processes, the calling thread shall block until all of the children of the process containing the calling thread terminate, and wait() and waitpid() shall fail and set errno to [ECHILD].[/XSI]After Issue7+TC1 XSH chapter 3 wait() and waitpid() application usage page 2208 after line 70110, insert: [XSI]As specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549, if the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, then the termination of a child process will not cause status information to become available to a thread blocked in wait(), waitid(), or waitpid(). Thus, a thread blocked in one of the wait functions will remain blocked unless some other condition causes the thread to resume execution (such as an [ECHILD] failure due to no remaining children in the set of waited-for children).[/XSI]At Issue7+TC1 XSH chapter 3 waitid() description page 2212 lines 70244-70250, change: The waitid() function shall suspend the calling thread until one child of the process containing the calling thread changes state. It records the current state of a child in the structure pointed to by infop. The fields of the structure pointed to by infop are filled in as described for the SIGCHLD signal in <signal.h>. If a child process changed state prior to the call to waitid(), waitid() shall return immediately. If more than one thread is suspended in wait(), waitid(), or waitpid() waiting for termination of the same process, exactly one thread shall return the process status at the time of the target process termination.to: The waitid() function shall obtain status information (see XSH Section 2.13) pertaining to termination, stop, and/or continue events in one of the caller's child processes.After Issue7+TC1 XSH chapter 3 waitpid() application usage at page 2213 line 70293, insert: [XSI]As specified under "Consequences of Process Termination" in the description of the _Exit() function on page 549, if the calling process has SA_NOCLDWAIT set or has SIGCHLD set to SIG_IGN, then the termination of a child process will not cause status information to become available to a thread blocked in wait(), waitid(), or waitpid(). Thus, a thread blocked in one of the wait functions will remain blocked unless some other condition causes the thread to resume execution (such as an [ECHILD] failure due to no remaining children in the set of waited-for children).[/XSI]After Issue7+TC1 XRAT section B.2.12.3 page 3649 line 124639, insert: B.2.13 Status Information |
|
Restarting the interpretation clock with a revised proposal. Interpretation Proposed 27 Sep 2013 |
|
Interpretation approved 28 Oct 2013 |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-05-07 06:18 | tedu | New Issue | |
2013-05-07 06:18 | tedu | File Added: w.c | |
2013-05-07 06:18 | tedu | Name | => Ted Unangst |
2013-05-07 06:18 | tedu | Organization | => OpenBSD |
2013-05-07 06:18 | tedu | Section | => waitpid |
2013-05-07 06:27 | philip-guenther | Note Added: 0001590 | |
2013-05-12 19:28 | rhansen | Note Added: 0001602 | |
2013-05-12 19:50 | rhansen | Note Edited: 0001602 | |
2013-05-13 15:32 | eblake | Relationship added | related to 0000594 |
2013-05-15 03:01 | rhansen | Note Edited: 0001602 | |
2013-05-16 15:17 | rhansen | Note Edited: 0001602 | |
2013-05-16 15:26 | rhansen | Note Edited: 0001602 | |
2013-05-16 15:32 | rhansen | Note Edited: 0001602 | |
2013-05-16 15:35 | rhansen | Note Edited: 0001602 | |
2013-05-16 15:38 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:35 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:36 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:36 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:38 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:39 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:44 | rhansen | Note Edited: 0001602 | |
2013-05-17 16:45 | rhansen | Note Edited: 0001602 | |
2013-05-17 20:23 | rhansen | Note Edited: 0001602 | |
2013-05-17 20:29 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:22 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:30 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:35 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:36 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:37 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:39 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:41 | rhansen | Note Edited: 0001602 | |
2013-05-17 21:42 | rhansen | Note Edited: 0001602 | |
2013-05-17 22:05 | rhansen | Note Edited: 0001602 | |
2013-05-17 22:15 | rhansen | Note Edited: 0001602 | |
2013-05-17 22:19 | rhansen | Note Edited: 0001602 | |
2013-05-17 22:23 | rhansen | Note Edited: 0001602 | |
2013-05-17 22:24 | rhansen | Note Edited: 0001602 | |
2013-05-17 22:29 | rhansen | Note Edited: 0001602 | |
2013-05-20 13:30 | rhansen | Note Edited: 0001602 | |
2013-05-20 20:09 | rhansen | Note Edited: 0001602 | |
2013-05-20 20:12 | rhansen | Note Edited: 0001602 | |
2013-05-20 20:16 | rhansen | Note Edited: 0001602 | |
2013-05-20 20:23 | rhansen | Note Edited: 0001602 | |
2013-05-20 21:10 | rhansen | Note Edited: 0001602 | |
2013-05-23 15:31 | rhansen | Note Edited: 0001602 | |
2013-05-23 15:42 | rhansen | Note Edited: 0001602 | |
2013-05-23 15:48 | rhansen | Note Edited: 0001602 | |
2013-05-23 15:50 | rhansen | Note Edited: 0001602 | |
2013-05-23 15:50 | geoffclare | Note Added: 0001625 | |
2013-05-23 15:57 | geoffclare | Interp Status | => Pending |
2013-05-23 15:57 | geoffclare | Final Accepted Text | => 0000690:0001625 |
2013-05-23 15:57 | geoffclare | Status | New => Interpretation Required |
2013-05-23 15:57 | geoffclare | Resolution | Open => Accepted As Marked |
2013-05-23 15:57 | geoffclare | Tag Attached: tc2-2008 | |
2013-09-06 04:56 | ajosey | Interp Status | Pending => Proposed |
2013-09-06 04:56 | ajosey | Note Added: 0001812 | |
2013-09-27 04:21 | rhansen | Note Added: 0001855 | |
2013-09-27 04:23 | rhansen | Note Edited: 0001855 | |
2013-09-27 05:58 | Don Cragun | Page Number | => 491, 549-550, 1932, 2203, 2212 |
2013-09-27 05:58 | Don Cragun | Line Number | => 16773-16779, 19051-19072, 61931-61938, 69847-69856, 69881-69884, 70244-70250 |
2013-09-27 05:58 | Don Cragun | Interp Status | Proposed => Pending |
2013-09-27 05:58 | Don Cragun | Note Edited: 0001625 | |
2013-09-27 06:00 | Don Cragun | Section | waitpid => XSH 2.4.3, _Exit(), sigaction(), wait(), waitpid(), waitid(), wait() |
2013-09-27 13:09 | ajosey | Interp Status | Pending => Proposed |
2013-09-27 13:09 | ajosey | Note Added: 0001856 | |
2013-10-28 14:17 | ajosey | Interp Status | Proposed => Approved |
2013-10-28 14:17 | ajosey | Note Added: 0001947 | |
2013-11-08 10:35 | geoffclare | Relationship added | has duplicate 0000788 |
2013-11-15 05:24 | eblake | Relationship added | related to 0000792 |
2015-07-06 16:21 | rhansen | Relationship added | related to 0000947 |
2015-07-10 21:39 | rhansen | Relationship added | related to 0000959 |
2019-06-10 08:55 | agadmin | Status | Interpretation Required => Closed |