简体   繁体   English

Perl中的外部过程完成超时(Windows)

[英]Time out for external process completion in perl (windows)

I'm writing a perl program for windows, that runs several SVN commands. 我正在为Windows编写一个perl程序,该程序运行多个SVN命令。

I need to receive the status of the SVN process so i'm using "back ticks". 我需要接收SVN进程的状态,所以我正在使用“后退”。

eg: 例如:

{
$COMMAND="blabla...";
$results=`$COMMAND 2>&1`;
parse_results($results);
}

Sometimes the process gets stuck, so I need to set timeout to the process. 有时,进程卡住了,因此我需要为进程设置超时。

I tried to use "ALARM" signal but it didn't kill the stuck process. 我尝试使用“ ALARM”信号,但它没有杀死卡住的进程。 I receive the indication only if and when the process finishes. 仅当过程完成时,我才会收到指示。

What can I do to deal with processes that don't complete fast enough? 我该怎么办才能处理速度不够快的流程?

Signals are a unix concept. 信号是unix概念。 Instead, you should use IPC::Run . 相反,您应该使用IPC :: Run

use IPC::Run qw( run timeout );

run [ 'bla', 'arg' ], '>&', \my $results, timeout( 10 )
   or die "bla: $?"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM