Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1e394a37e86c12d1e85195b53f45cd4d9ace40de
Ticket: 219118ffffffffffffffffffffffffffffffffff
failed exec leaves defunct process
User & Date: nobody on 2000-10-26 01:11:03
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    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
    
  4. foundin changed to: "obsolete: 8.3.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "60. NRE and coroutines"
  10. title changed to: "failed exec leaves defunct process"
  11. type changed to: "Bug"