我正在编写一个perl脚本,需要在windows和linux中运行一个进程,如果需要太长时间就超时,如果没有超时,返回退出代码,如果退出代码为0,则返回stdout,并且没有超时。我在windows和linux上看到了不同的结果。在下面的代码中,我给了open3一个失败的命令(ping没有任何参数-z)。在linux上,代码立即返回一个负退出代码。在windows上,命令超时。在windows命令行上运行ping g
或者,我可以在子进程上设置某种时间过滤器,这样,如果东西在100到200 is之后没有更新,它就会转移到下一个进程吗?下面是我目前正在处理的代码的相关部分#remove whitespaces, etc from item.
#Run ping#subprocess.Popen runs cmdline ping, pipes the output to stdout. .stdout.read() then reads that streamdat