Skip to content
Tcl Source Code History Of Ticket 218120ffffffffff
Login

History Of Ticket 218120ffffffffff

Artifacts Associated With Ticket 218120ffffffffff

  1. Ticket change [006ba06a89] (rid 119319) by nobody on 2000-10-26 00:53:21:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 1941 Bug
      Version: 8.0.4
      SubmitDate: '1999-04-27'
      LastModified: '2000-04-26'
      Severity: SER
      Status: Closed
      Submitter: pat
      ChangedBy: hobbs
      OS: Solaris
      OSVersion: 2.6
      Machine: Other
      FixedDate: '2000-10-25'
      ClosedDate: '2000-04-26'
      
      
      Name:
      
      Tethys
      
      
      
      Extensions:
      
      BLT, expect (although sometimes none)
      
      
      
      CustomShell:
      
      Applied Jan Nijtman's plus/dash patches.
      
      
      
      Comments:
      
      I'm almost 100% sure my patch is NOT correct. However, it appears to be
      
          a usable workaround for the time being. I don't know enough about Tcl
      
          channel handling to fix it properly.
      
      
      
      ReproducibleScript:
      
      Most Tcl scripts containing an "exec" command that returns data.
      
          
      
          wish -f foo.tcl
      
          
      
          Note that *some* scripts work fine. Others (seemingly at random) fail.
      
          An earlier posting to comp.lang.tcl pointed me to GetInput(), but the
      
          recommended patch (treating EINTR the same as EAGAIN / EWOULDBLOCK)
      
          didn't work for me.
      
      
      
      ObservedBehavior:
      
      An error message:
      
          
      
          error reading output from command: interrupted system call
      
      
      
      DesiredBehavior:
      
      The "exec" command not causing an error. The same scripts work fine with
      
          tcl7.6
      
      
      
      Patch:
      
      *** tclIO.c     Mon Apr 26 13:46:35 1999
      
      --- tclIO.c.orig        Thu Apr 22 18:15:52 1999
      
      ***************
      
      *** 2717,2726 ****
      
                  } else {
      
                      panic("Blocking channel driver did not block on input");
      
                  }
      
      - #ifndef TREAT_EINTR_AS_ERROR
      
      -       } else if (result == EINTR) {
      
      -               result = 0;
      
      - #endif /* TREAT_EINTR_AS_ERROR */
      
              } else {
      
                  Tcl_SetErrno(result);
      
              }
      
      --- 2717,2722 ----
      
      
      
      PatchFiles:
      
      tclIO.c
      
      
      
      
      
      We need something reproducable to go any further with this report. 
      -- 04/26/2000 hobbs
      
    4. foundin initialized to: "obsolete: 8.0.4"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "60. NRE and coroutines"
    10. title initialized to: "exec command fails with EINTR"
    11. type initialized to: "Bug"
  2. Ticket change [c249b7fffa] (rid 111463) by welch on 2000-10-26 08:14:48:

    1. closedate changed to: "2000-10-26T01:14:48"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [5280d1b8b0] (rid 126326) by bluemoon on 2000-11-29 04:18:53:

    1. icomment:
      This is the same problem as bug 118076 and they're trying a similar fix.
      Essentially, Tcl is ignoring EINTR from read(). The valid response to this
      interrupt is to re-enter the read() and ignore the error. The program
      cannot control this action within an interrupt handler.
      
      
    2. login: "bluemoon"
    3. mimetype: "text/plain"
    4. username: "bluemoon"
  4. Ticket change [104f61b308] (rid 94950) by dgp on 2001-04-05 08:20:14:

    1. closedate changed to: "2001-04-05T01:20:14"
    2. closer changed to: "dgp"
    3. subsystem changed to: "27. Channel Types"
  5. Ticket change [c5af7a98bb] (rid 112043) by nobody on 2001-04-05 22:51:23:

    1. icomment:
      Logged In: NO 
      
      Reproducing this is difficult because it is dependent on
      what the kernel is doing and what is specifically running
      on a specific machine at the time. I've noticed a much
      higher occurrence on hpux 10.20 machines than any others.
      
      With that said, I don't believe its necessary to reproduce
      a problem that is caused by the improper coding of unix io.
      The low level unix io functions (on some platforms) can be
      interrupted at any time by the system for any reason. When
      this occurs the function returns an "error", but this needs
      to be interpreted. The interpretation is to check errno for
      EINTR. EINTR implies that the io was simply stopped to allow
      interrupt handling to occur. Handling the interrupt is
      actually a non-issue. But if an interrupt handler is in place,
      it will occur asynchronously to the process and control will
      be returned to where the io call is. At this point the io
      should be restarted. No data is ever moved when it is
      interrupted due to EINTR, so nothing can be lost. If no
      interrupt handler is in place, the io is still halted and still
      needs to be restarted.
      
      Some of the io functions that do this are read(), write(),
      fgetc(), and fputc(). Interestingly, wait's also work this
      way. Take a look at the Tcl 8.3, compat/waitpid.c, and
      see how the waitpid() function handles return codes
      from wait() or wait3().
      
      The patch given above may work, but isn't really proper.
      The real fix should be to root out all of the low level io calls
      and loop them when the call fails due to EINTR. read() (and
      probably write()) seems to be the most used offender.
      
      read() is simpler but here's an example of fgetc() which
      shows the "quirkiness" of unix io.
      
            cp = buffer;
            for(i = 0; i<(sizeof(buffer)-1); i++) {
               /* Read chars until a true EOF/io error or a good char is read */
               while ((ch=fgetc(rfp)) == EOF) {
                  if (feof(rfp)) goto eof;
                  if (errno != EAGAIN && errno != EINTR) goto badio;
               }
               *cp++ = ch;
               if(ch == '\n') break;
            }
            *cp = 0;
      
      Note the checks for fgetc(). An EOF value is returned "if an error
      occurs", as described in the man page. The "error" now needs
      to be interpreted. A call to feof() needs to be made on the stream
      to determine if the EOF returned was indeed an actual EOF. If so,
      its not an error, just time to process EOF. Now look at the next
      tests for errno = EAGAIN or EINTR. If the errno is set to these,
      it still is not an error and the code simply continues.
      
      This is really how the io code in tcl should be handling these
      interrupts rather than trying to propogate EINTR up to a higher
      level. (Note also that EAGAIN is a possibility that is not handled
      by the tcl code at all). Higher level code should never have to
      be concerned with these interrupts. They can install interrupt
      handlers if they need to see them.
      
      Finally, I you don't want to take my word for it, take a look
      at a unix programming book. Something like "Advanced
      Programming in the UNIX Environment", by W. Richard Stevens,
      Addison-Wesley Publishing Company, Copyright 1992, section
      10.5, pages 275-277. Page 276 has the following text:
      
      "...The typical code sequence (assuming a read operation and
      assuming we want to restart the read even if it's interrupted)
      would be
      
      again:
         if ( (n = read(fd, buff, BUFFSIZE) ) < 0) {
            if (errno == EINTR)
               goto again;         /* just an interrupted system call */
         }
      
      To prevent the applications from having to handle interrupted system
      calls 4.2BSD introduced the automatic restarting of certain interrupted
      system calls..."
      
      "...POSIX.1 allows an implementation to restart system calls, but it is
      not required.
      
      System V has never restarted system calls by default...
      
      ... With 4.3+BSD the automatic restarting of system calls depends on
      which function is called to set the signal's disposition..."
      
      Its a little weak in the "assuming we want to restart the read" bit.
      There really is no reason to not restart the read. Especially since
      some vendors do and some don't. The only way to get consistency
      across vendors is to restart them.
      
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"