Skip to content
Tcl Source Code History Of Ticket 439114
Login

History Of Ticket 439114

Artifacts Associated With Ticket 439114

  1. Ticket change [97fe1b239e] (rid 110536) by chris_nelson on 2001-07-06 16:52:51:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      When running a child process on a open pipe, the buffering of the channel appears to affect the 
      [catch] of the [close] of the channel on [eof].
      
      I'll attach a script which reproduce this problem.  A C program which can be used to demonstrate it 
      is:
      
        #include <stdio.h>
      
        int main(int argc,char **argv)
        {
            fprintf(stderr, "child.c   : About To Exit NonZero...\n");
            exit(33);
        }
      
      When run in Tcl 8.2, the parent process correctly gets the child's exit status.  When run in Tcl, the 
      child process appears to always succeed.
      
       urchin{53}hyper/v5.0.3/eofError > /usr/local/bin/tclsh8.2
       % source t.tcl
       % works
       child.c   : About To Exit NonZero...
       <<>>Got EOF on file3
               Set FioStatus to 1 from catch of close
               errorCode:CHILDSTATUS 9311 33
       PtiExec(FioStatus):1
       % fails
       child.c   : About To Exit NonZero...
       <<>>Got EOF on file3
               Set FioStatus to 1 from catch of close
               errorCode:CHILDSTATUS 9312 33
       PtiExec(FioStatus):1
       % urchin{54}hyper/v5.0.3/eofError > /usr/local/bin/tclsh8.4
       % source t.tcl
       % works
       child.c   : About To Exit NonZero...
       <<>>Got EOF on file3
               Set FioStatus to 1 from catch of close
               errorCode:CHILDSTATUS 9316 33
       PtiExec(FioStatus):1
       % fails
       child.c   : About To Exit NonZero...
       <<>>Got EOF on file3
              Set FioStatus to 0 from catch of close
              errorCode:CHILDSTATUS 9316 33
       PtiExec(FioStatus):0
      
      
    4. foundin initialized to: "obsolete: 8.4a3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "chris_nelson"
    9. subsystem initialized to: "25. Channel System"
    10. title initialized to: "Channel buffering affects [close] status"
    11. type initialized to: "Bug"
  2. Ticket change [e878070c1b] (rid 104649) by chris_nelson on 2001-07-06 23:52:52:

    1. icomment:
      
      
      File Added - 8135: t.tcl
      
      
      
    2. login: "chris_nelson"
    3. mimetype: "text/plain"
    4. username: "chris_nelson"
  3. Add attachment "t.tcl" [e9b9724d92] (rid 104857) by chris_nelson on 2001-07-06 23:52:52.

  4. Add attachment "child.c" [a286f6540d] (rid 109911) by dgp on 2001-07-13 02:23:16.

  5. Ticket change [bb17060ddf] (rid 129417) by dgp on 2001-07-13 02:23:17:

    1. icomment:
      
      
      File Added - 8354: child.c
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  6. Ticket change [8312b35b75] (rid 117335) by dgp on 2001-07-13 05:16:15:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Thanks for including the test scripts.  They help a lot.
      
      Now the bad news.  Your test scripts fail on all releases
      of Tcl that I've tested:
      
      $ tclsh7.6
      % source t.tcl
      % works
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:$::errorCode
      can't wait for variable "::PtiExec(FioDone)":  would wait
      forever
      % fails
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:$::errorCode
      can't wait for variable "::PtiExec(FioDone)":  would wait
      forever
      % exit
      
      $ tclsh8.0
      % info patch
      8.0.5
      % source t.tcl
      % works
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:CHILDSTATUS 16053 33
      PtiExec(FioStatus):1
      % fails
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:CHILDSTATUS 16054 33
      PtiExec(FioStatus):1
      % Blocking channel driver did not block on input
      Abort
      
      $ tclsh8.1
      % info patch
      8.1.1
      % source t.tcl
      % works
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:CHILDSTATUS 16057 33
      PtiExec(FioStatus):1
      % fails
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:CHILDSTATUS 16058 33
      PtiExec(FioStatus):1
      % $
      
      Note that the script aborts tclsh8.1, but there is no
      panic message this time.  This same behavior is also
      observed in 8.2.0 and 8.2.1 and 8.2.2.
      
      Then in 8.2.3:
      
      $ tclsh8.2
      % info patch
      8.2.3
      % source t.tcl
      % works
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 1 from catch of close
              errorCode:CHILDSTATUS 25060 33
      PtiExec(FioStatus):1
      % fails
      child.c : About To Exit NonZero...
      <<>>Got EOF on file3
              Set FioStatus to 0 from catch of close
              errorCode:CHILDSTATUS 25060 33
      PtiExec(FioStatus):0
      % $
      
      Now the [close] doesn't throw an error, which seems to
      be the bug you are reporting, so that misbehavior first
      showed up in Tcl 8.2.3, but notice the tclsh still aborts!
      
      That behavior is also exhbited by 8.3.3 and 8.4a3, and I'm
      assuming also all the 8.3.x and 8.4ax releases.   Except
      for the aborting, that's what you report for 8.4a3 as well.
      
      You don't see aborts?
      
      So, anyway, I'd look into the changes between 8.2.2 and
      8.2.3 for the cause of the change in behavior of [close],
      but I don't see any version of Tcl (on Solaris 8) for which
      your scripts will work.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [f584828bd0] (rid 130121) by dgp on 2001-07-13 05:38:36:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      OK, the particular change between 8.2.2 and 8.3.3 releases
      that changed the behavior is that noted in the Changelog:
      
      1999-11-29  Jeff Hobbs  <[email protected]>
      
              * unix/tclUnixPipe.c: fixed PipeBlockModeProc to
      properly set
              isNonBlocking flag on pipe. [Bug: 1356 710]
              removed spurious fcntl call from PipeBlockModeProc
      
      You can restore the 8.2.2 behavior by commenting out
      line 836 of revision 1.12 of unix/tclUnixPipe.c .  Just
      tested that on the HEAD revision.  That's just information,
      not a recommendation.
      
      FYI, Bugs 1356 and 710 are now known as Bugs 218588
      and 218492, respectively.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  8. Ticket change [88ab31b8eb] (rid 131905) by chris_nelson on 2001-07-13 20:55:07:

    1. icomment:
      Logged In: YES 
      user_id=107514
      
      I guess I _was_ seeing aborts but I was ignoring them and could get rid of them by removing an 
      unnecessary command:
      
           fconfigure stdout -buffering none -blocking 0 -translation binary
      
      I see that dropping the child status showed up in 8.2.3 and that I should look at tclUnixPipe.c.  Thanks.
      
      
      
    2. login: "chris_nelson"
    3. mimetype: "text/plain"
    4. username: "chris_nelson"
  9. Ticket change [6d676eb79b] (rid 128690) by chris_nelson on 2001-07-13 22:19:42:

    1. icomment:
      Logged In: YES 
      user_id=107514
      
      OK.  The problem seems to be in PipeCloseProc which says:
      
          if (pipePtr->isNonBlocking || TclInExit()) {
          
              /*
               * If the channel is non-blocking or Tcl is being cleaned up, just
               * detach the children PIDs, reap them (important if we are in a
               * dynamic load module), and discard the errorFile.
               */
              
              Tcl_DetachPids(pipePtr->numPids, pipePtr->pidPtr);
              Tcl_ReapDetachedProcs();
      
              if (pipePtr->errorFile) {
          TclpCloseFile(pipePtr->errorFile);
              }
          } else {
              
              /*
               * Wrap the error file into a channel and give it to the cleanup
               * routine.
               */
      
              if (pipePtr->errorFile) {
          errChan = Tcl_MakeFileChannel(
      (ClientData) GetFd(pipePtr->errorFile), TCL_READABLE);
              } else {
                  errChan = NULL;
              }
              result = TclCleanupChildren(interp, pipePtr->numPids, pipePtr->pidPtr,
                      errChan);
          }
      
      The first clause isn't specific enough, we only want to discard or ignore the child's status if the child is still 
      running.  If the pipe is nonblocking BUT the child is done, we _can_ (and should!) get the child's exit status. 
      I'm looking into how to determine if the child is done or not.
      
      
      
    2. login: "chris_nelson"
    3. mimetype: "text/plain"
    4. username: "chris_nelson"
  10. Ticket change [ede94e643c] (rid 103986) by andreas_kupries on 2001-07-17 01:53:04:

    1. assignee changed to: "hobbs"
  11. Ticket change [ba5f9630c0] (rid 129313) by hobbs on 2001-12-13 08:18:43:

    1. assignee changed to: "andreas_kupries"
  12. Ticket change [dd1fd91a75] (rid 114605) by andreas_kupries on 2001-12-14 01:15:38:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Chris, did you have the time to "look into how to determine 
      if the child is done or not" ?
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  13. Ticket change [84339e7b51] (rid 117505) by chris_nelson on 2001-12-14 03:19:41:

    1. icomment:
      Logged In: YES 
      user_id=107514
      
      I looked a bit but got dizzy looking at unfamiliar channel and process management code.  Sorry.
      
      
    2. login: "chris_nelson"
    3. mimetype: "text/plain"
    4. username: "chris_nelson"