failed exec leaves defunct process
Closed / Fixed219118ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:11:03
OriginalBugID: 6148 Bug
Version: 8.3.2
SubmitDate: '2000-08-18'
LastModified: '2000-09-06'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 5759
OS: Solaris
OSVersion: Solaris 2.7
Machine: multiprocessor Sparc (E450 I think)
FixedDate: '2000-09-06'
FixedInVersion: 8.4a2
ClosedDate: '2000-10-25'
Name:
Rob Mayoff
Comments:
The problem is that the child writes its error code to the pipe and then
exits. The parent reads the code and then calls waidpid with the
WNOHANG flag. The problem is that the parent might read the code and
call waitpid before the child has reached the exit call, in which case
waidpid returns 0. There is no reason for the parent to use the WNOHANG
flag. Eliminating the WNOHANG flag removes the race condition.
This problem also exists in Tcl 7.6.
ReproducibleScript:
# Run this in an interactive tclsh:
for {set i 0} {$i < 100} {incr i} {
catch {exec /this/file/does/not/exist}
}
ObservedBehavior:
On a multiprocessor Solaris machine, when an exec fails, there is a possibility of the failed child not being waited on and hanging around as a zombie (defunct process), due to a race condition. The sample script above generated about 33 zombies in one test.
DesiredBehavior:
No zombies!
Patch:
*** tclUnixPipe.c 2000/08/15 01:11:05 1.1.1.1
--- tclUnixPipe.c 2000/08/15 03:57:23 1.2
***************
*** 447,453 ****
* startup.
*/
! Tcl_WaitPid((Tcl_Pid) pid, &status, WNOHANG);
}
if (errPipeIn) {
--- 447,453 ----
* startup.
*/
! Tcl_WaitPid((Tcl_Pid) pid, &status, 0);
}
if (errPipeIn) {
PatchFiles:
unix/tclUnixPipe.c
Fixed in 8.4a2.
-- 09/06/2000 hobbs
welch Closed ticket [219118ffff].
[History diff]2000-10-26 08:34:57
dgp Ticket [219118ffff]: 3 changes
[History diff]2001-04-05 08:20:12
Log in (anonymous is fine) to add a comment.