Last active
August 29, 2015 13:56
-
-
Save dgsb/9209160 to your computer and use it in GitHub Desktop.
Expect core dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# \ | |
exec tclsh "$0" "$@" | |
set nb_iter 1000 | |
set sleep 500 | |
for {set i 0} {$i < $nb_iter} {incr i} { | |
after $sleep | |
puts $i | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# \ | |
exec tclsh "$0" "$@" | |
package require Expect | |
set nb_subproc 20 | |
set sid_list [list] | |
set ::completed {} | |
for {set i 0} {$i < $nb_subproc} {incr i} { | |
spawn [file normalize [file join [file dirname $::argv0] runnee.tcl]] | |
lappend sid_list $spawn_id | |
expect_background { | |
-i $spawn_id eof [list set ::completed $spawn_id] | |
} | |
} | |
set aid [after 1200000 {set ::completed timeout}] | |
while {[llength $sid_list] > 0} { | |
vwait ::completed | |
if {"timeout" eq $::completed} { | |
error timeout | |
} | |
set idx [lsearch $sid_list $::completed] | |
if {-1 == $idx} { | |
error "spawn_id $spwan_id not found in \"$sid_list\"" | |
} | |
set sid_list [concat [lrange $sid_list 0 $idx-1] [lrange $sid_list $idx+1 end]] | |
} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
afaik, there is no guarantee that
vwait
returns for everyset ::completed
. Should be re-writtenlappend ::completed $spawn_id
and wrap the removal inforeach sid $::completed {...} ; set ::completed {}
.