我正在按照这里的示例 https://wiki.tcl-lang.org/page/Execute+in+Parallel+and+Wait 但是当我运行这样的简单代码时出现错误:子进程异常退出并且错误是“错误:无法找到或加载主类原因:java.lang.ClassNotFoundException:”
for {set i 0} {$i < 5} {incr i} {
set script {
puts hello
}
set chan [open |[list [info nameofexecutable] <<$script 2>@stderr]]
dict set res $chan command $script
fconfigure $chan -blocking 0
lappend background $chan
}
while 1 {
foreach chan $background {
if {[eof $chan]} {
fconfigure $chan -blocking 1
if {[set idx [lsearch -exact $background $chan]] >= 0} {
set background [lreplace $background $idx $idx]
}
catch [close $chan] cres copts
dict set res $chan result $cres
dict set res $chan options $copts
} else {
puts -nonewline [read $chan]
}
}
if {[llength $background] == 0} {
break
}
after 100
}
return $res
}
}
尝试通过在 forloop 中运行此执行语句以稍微不同的方式运行并行进程时,我收到了类似的消息
exec [info nameofexecutable] $variable_of_path_to_script << [list proc_name $param1 $param2] 2>@stderr