Hello,
I am new to this site, so sorry ahead of time if this is not the right place for this question.......anywhooooo
I am having troubles with forking new processes in wish. Take the following code example:
****************************
package require Tclx
puts "TCL VER: [info tclversion]"
proc spawnChildren {} {
for {set i_vii 0} {$i_vii < 5} {incr i_vii} {
set temp_vii [fork]
if {$temp_vii == 0} {
# Child Process
puts "child pid is: [pid]"
exit 1
} else {
# Parent Process
puts "parent\[[pid]\]: sees the child pid as $temp_vii"
# Store off child pids to collect later
lappend finalPid_vil $temp_vii
}
}
foreach pid_vii $finalPid_vil {
# Collect all zombie child process
wait $pid_vii
}
puts "parent out of loop: $finalPid_vil"
}
# Spawn 5 children off
spawnChildren
puts "out of spawning"
***************************
If I run this TCL script with tclsh I get the following output:
Monday|May.05|03:25PM> tclsh temp.tcl
TCL VER: 8.4
child pid is: 10469
parent[10468]: sees the child pid as 10469
child pid is: 10470
parent[10468]: sees the child pid as 10470
child pid is: 10471
parent[10468]: sees the child pid as 10471
parent[10468]: sees the child pid as 10472
child pid is: 10473
parent[10468]: sees the child pid as 10473
child pid is: 10472
parent out of loop: 10469 10470 10471 10472 10473
out of spawning
PERFECT...Just like I expect
But now I run it with Wish:
Monday|May.05|03:27PM> wish temp.tcl
TCL VER: 8.4
child pid is: 10481
parent[10480]: sees the child pid as 10481
child pid is: 10482
X connection to :0.0 broken (explicit kill or server shutdown).
parent[10480]: sees the child pid as 10482
child pid is: 10483
X connection to :0.0 broken (explicit kill or server shutdown).
parent[10480]: sees the child pid as 10483
child pid is: 10484
X connection to :0.0 broken (explicit kill or server shutdown).
parent[10480]: sees the child pid as 10484
child pid is: 10485
parent[10480]: sees the child pid as 10485
X connection to :0.0 broken (explicit kill or server shutdown).
parent out of loop: 10481 10482 10483 10484 10485
out of spawning
X connection to :0.0 broken (explicit kill or server shutdown).
Why am I receiving these X Errors? Is wish overriding the normal exit procedure and then causing havoc?
I am running redhat 4.0 Enterprise with Tcl 8.4. Any help would be greatly appreciated. Thanks ahead of time!!!
I am new to this site, so sorry ahead of time if this is not the right place for this question.......anywhooooo
I am having troubles with forking new processes in wish. Take the following code example:
****************************
package require Tclx
puts "TCL VER: [info tclversion]"
proc spawnChildren {} {
for {set i_vii 0} {$i_vii < 5} {incr i_vii} {
set temp_vii [fork]
if {$temp_vii == 0} {
# Child Process
puts "child pid is: [pid]"
exit 1
} else {
# Parent Process
puts "parent\[[pid]\]: sees the child pid as $temp_vii"
# Store off child pids to collect later
lappend finalPid_vil $temp_vii
}
}
foreach pid_vii $finalPid_vil {
# Collect all zombie child process
wait $pid_vii
}
puts "parent out of loop: $finalPid_vil"
}
# Spawn 5 children off
spawnChildren
puts "out of spawning"
***************************
If I run this TCL script with tclsh I get the following output:
Monday|May.05|03:25PM> tclsh temp.tcl
TCL VER: 8.4
child pid is: 10469
parent[10468]: sees the child pid as 10469
child pid is: 10470
parent[10468]: sees the child pid as 10470
child pid is: 10471
parent[10468]: sees the child pid as 10471
parent[10468]: sees the child pid as 10472
child pid is: 10473
parent[10468]: sees the child pid as 10473
child pid is: 10472
parent out of loop: 10469 10470 10471 10472 10473
out of spawning
PERFECT...Just like I expect
But now I run it with Wish:
Monday|May.05|03:27PM> wish temp.tcl
TCL VER: 8.4
child pid is: 10481
parent[10480]: sees the child pid as 10481
child pid is: 10482
X connection to :0.0 broken (explicit kill or server shutdown).
parent[10480]: sees the child pid as 10482
child pid is: 10483
X connection to :0.0 broken (explicit kill or server shutdown).
parent[10480]: sees the child pid as 10483
child pid is: 10484
X connection to :0.0 broken (explicit kill or server shutdown).
parent[10480]: sees the child pid as 10484
child pid is: 10485
parent[10480]: sees the child pid as 10485
X connection to :0.0 broken (explicit kill or server shutdown).
parent out of loop: 10481 10482 10483 10484 10485
out of spawning
X connection to :0.0 broken (explicit kill or server shutdown).
Why am I receiving these X Errors? Is wish overriding the normal exit procedure and then causing havoc?
I am running redhat 4.0 Enterprise with Tcl 8.4. Any help would be greatly appreciated. Thanks ahead of time!!!