简单的TCL挂
我使用非常简单的 TCL 脚本来重现我的问题。我在带有 activeTCL 8.6.4.1 的 Windows 7 上运行。
我使用一个简单的批处理文件 (loop.bat),它在循环中调用 tcl 脚本 (1.tcl)。然后该脚本执行一些“放置”并打开另一个 TCL shell 以调用另一个 TCL 脚本 (2.tcl)。第二个脚本执行两次“放置”,一个在 stdout 上,一个在 stderr 上,然后返回。
为了重现该问题,我启动了 16 个 loop.bat 实例并让它运行了一整夜。当我早上回来时,大约有一半的实例停止(挂起)。
这是我使用的代码:
循环文件
@echo off
:loop
tclsh86 1.tcl
goto loop
1.tclputs "start 1.tcl"
set error [catch {eval {exec tclsh86 2.tcl >@stdout 2>@stderr}} results]
puts "error = $error"
puts "results = $results"
puts "end 1.tcl"
return 0
2.tclputs stdout "Print to stdout from 2.tcl."
puts stderr "Print to stderr from 2.tcl."
return 1
最佳答案
To reproduce the problem, I launch 16 instances of loop.bat and let it run for a whole night. When I come back in the morning, about half of the instances are stalled (hung).
使用“exec”、“puts”地址和批处理循环的迭代创建了新线程和文件套接字。如果套接字或线程的创建速度比恢复速度快,则调用的“子”进程最终将耗尽可用的套接字或线程。
这可能有助于解释:https://web.archive.org/web/20190217153445/https://blogs.msdn.microsoft.com/oldnewthing/20050729-14/?p=34773
关于TCL 假卡在退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32351462/