| |||||||||||
There are some defunct processes after close socke Posted by rdczhju (rdczhju), 25 August 2004 Hi, There are some defunct processes after I close sockets. I don't know why and how did this happen? would you please give me some comments on my script? I paste my socket server script here: #!/opt/sfw/bin/expect -- set PORT 7777 proc Listener { newSock addr port } { puts "New client $newSock from $addr port $port" fconfigure $newSock -buffering line fileevent $newSock readable [ list Handler $newSock ] } proc Handler {sock} { global env if { [ eof $sock] || [catch {gets $sock line} ] } { close $sock puts "Close socket." } else { switch -regexp -- $line { ^QUIT$ { close $sock puts "Close socket on demand." } {^\[DIST\]} { set info [lindex [split $line =] 1] set dist [lindex [split $info] 0] set env(DIST_LIB_PATH) [lindex [split $info] 1] if [ catch { exec $dist <@ $sock >@ $sock 2>@ stderr & } Catch ] { puts $sock "\[ERROR\]: $dist can't be started ($Catch)." } fileevent $sock readable "" close $sock } default { puts $sock "\[SERVER\]" } } } } if { $argc == 0 } { while 1 { spawn -noecho $argv0 $PORT wait } } else { set port [ lindex $argv 0 ] set s [ socket -server Listener [ format "%d" $port ] ] vwait forever } Is there some wrong with my script? thanks in advance! Posted by admin (Graham Ellis), 26 August 2004 Oh help! It's a morning for excellent specialist questions here. Not sure how much I can help .... but I CAN tell you that one of the usual reasons for defunct processes or zombies being left after a child process completes is that children always send a signal (SIGCHLD) to the parent when they exit and they hang around until the parent has received it. Sounds like what's happening here? I would be very tempted to get your Tcl to receive and ignore SIGCHLD signals and ignore them. If youwant to search the net for examples, the action of receiveing and ignoring child terminations is often known as "reaping children".This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |