Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0069b23f069fa18ae1629307deba34a5809ed750
Ticket: 3536564fffffffffffffffffffffffffffffffff
tcl hangs on parallel execution of commands using open
User & Date: anonymous on 2012-06-20 11:28:05
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hi, 
    
     I am looking to run a couple of processes in parallel. But a strange hang occurs randomly. I am invoking two tcl commands using open in parallel. Now after a while one of the process would just hang indefinitely which I am not able to understand why. The issue is easily reproducible on win 2008 server and other multi core machines. Am I doing something wrongly? What is the best way to do this? 
    
    To reproduce, you just have to create the files and run loop.bat. You should see the hang within 15-20 minutes. 
    
    Following are the files I am using 
    
    ******** 
    loop.bat 
    ****** 
    @echo off 
    :loop 
    tclsh 1.tcl 
    goto loop 
    
    ***************** 
    Contents of file 1.tcl 
    ***************** 
    #!/bin/sh 
    #DO NOT CHANGE THOSE 3 FIRST LINES \ 
    exec tclsh $0 "$@" 
    
    set status [catch { exec tclsh 2.tcl } outcmd] 
    puts $outcmd 
    exit 0 
    
    ******* 
    Contents of file 2.tcl 
    ***** 
    #!/bin/sh 
    #DO NOT CHANGE THOSE 3 FIRST LINES \ 
    exec tclsh $0 "$@" 
    
    set cmd1 "tclsh 6.tcl &" 
    set cmd2 "tclsh 5.tcl &" 
    set out1 "" 
    set out2 "" 
    
    proc isProcessDone { channel logText } { 
        gets $channel currentline 
        while {[eof $channel] == 0} { 
            set logText "$logText\n $currentline" 
            gets $channel currentline 
        } 
        return $logText 
    } 
    
    puts "hi" 
    set imChannel1 [open "| $cmd1"] 
    puts "hi1 $imChannel1" 
    set imChannel2 [open "| $cmd2"] 
    puts "hi2 $imChannel2" 
    #set imChannel3 [open "| $cmd"] 
    
    
    if { ${imChannel1} != "" } { 
            puts 1 
            fileevent $imChannel1 readable [set out1 [isProcessDone $imChannel1 $out1]] 
            puts 11 
            puts $out1 
    } 
    
    if { ${imChannel2} != "" } { 
            puts 2 
            fileevent $imChannel2 readable [set out2 [isProcessDone $imChannel2 $out2]] 
            puts 22 
            puts $out2 
    } 
    
    puts "bye" 
    
    exit 0 
    
    **** 
    Contents of 5.tcl and 6.tcl 
    ****** 
    #!/bin/sh 
    #DO NOT CHANGE THOSE 3 FIRST LINES \ 
    exec tclsh $0 "$@" 
    
    puts "\ncallexec 6 started" 
    puts "\ncallexec 6 terminated" 
    
    Please help. 
    
    TIA. 
    Deepanshu 
    
  4. foundin changed to: "obsolete: 8.4.15"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. subsystem changed to: "24. Channel Commands"
  10. title changed to:
    tcl hangs on parallel execution of commands using open
    
  11. type changed to: "Bug"