Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 113bc74936a3de45083d3fb88da6ce3de11639e5
Ticket: 218087ffffffffffffffffffffffffffffffffff
spawn and eof
User & Date: nobody on 2000-10-26 00:53:01
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 1721 Bug
    Version: 8.0p2
    SubmitDate: '1999-04-05'
    LastModified: '1999-12-03'
    Severity: CRIT
    Status: Closed
    Submitter: pat
    ChangedBy: hobbs
    OS: HP-UX
    OSVersion: 10.20
    Machine: Other
    FixedDate: '2000-10-25'
    ClosedDate: '1999-12-03'
    
    
    ReproducibleScript:
    #!/opt/expect-5.25/bin/expect -f
    
    set verbose 1
    log_user 1
    exp_internal -f tclose.log 1  
    
    proc send_value {pos val} {
    #   expect $pos
       send_user $pos\n
       send_user $val\n
    }
    
    proc send_verb {pos1 pos2 verb retain control_string} {
       send_value $pos1 $verb
       send_value $pos2 $retain
       send_user $control_string\n
    #   expect $control_string
    }
    
    set fin 0
    set fifoname /tmp/exp0.333
    set fifofile [open "|cat -u < /tmp/exp0.333" "r"]
    
    while {$fin == 0} { 
    
       catch {exec mkfifo /tmp/exp0.333} status
       exec chmod 666 /tmp/exp0.333
    
       # open will hang until other user's cat starts
    #   spawn -open [open "|cat -u < /tmp/exp0.333" "r"]
       spawn -open $fifofile
       set userin $spawn_id
    #   set userin 5
       send_user userin=$userin\n
    #   exp_pid
    
       while 1 {
    
          set spawn_id $userin
          expect {
             -re "\n" { set line1  "$expect_out(buffer)" }
             eof { 
                break
             }
          } 
    
          expect  -re "\n" { set line2  "$expect_out(buffer)" }
          expect  -re "\n" { set line3  "$expect_out(buffer)" }
    
          send_user line1=$line1\n\n
          send_user line2=$line2\n\n
          send_user line3=$line3\n\n
    
          if { [llength $line1] > 1 } {
              send_verb  [lindex $line2 0] [lindex $line2 1]  [lindex $line1 0] [lindex $line1 1]  "$line3"
          } else {
              send_bye  [lindex $line2 0]  [lindex $line1 0] \ 
                "$line3"
          }
      }
    
       catch {close -i $userin} status
    #   catch {close $fifofile} status
       send_user close_status=$status\n
       catch {exec rm -f $fifoname} status
       send_user rm-fifoname=$status\n
    
    }
    
    ObservedBehavior:
    we use expect and tcl/tk.
    our expect shell is blocked on a pipe open by spawn -open [open |cat -u < filename]
    when all datas in the pipe are read a trap on eof is executed and another process is done using datas just read.
    At the end of this process we wait again on pipe by making a new spawn.
    After some loops we always have the message "too many open files", why?
    
    
    
    open file ids must be being left open.  All file systems have
    some limit on the number of open files, and usually also have
    a per process limit. 
    -- 12/03/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.0p2"
  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: "spawn and eof"
  11. type changed to: "Bug"