perl – 如何知道使用Win32 :: Job启动的进程的状态

perl – 如何知道使用Win32 :: Job启动的进程的状态,第1张

概述我有以下内容以启动超时的进程 use Win32::Job;my $job = Win32::Job->new;# Run $command for $max_time$job->spawn($Config{"C:/Windows/System32/cmd.exe"}, $command, new_group);$job->run($max_time);$job_stat=$job-> 我有以下内容以启动超时的进程

use Win32::Job;my $job = Win32::Job->new;# Run $command for $max_time$job->spawn($Config{"C:/windows/System32/cmd.exe"},$command,new_group);$job->run($max_time);$job_stat=$job->status;print LOG "$command status $job_stat\n";

我阅读了Win32::Job CPAN指南,并添加了最后两行,因为我想知道该过程是否已完成或超时.这是正确的方法吗?

解决方法 根据 the documentation,status方法返回一个带有两个键的散列:exitcode和time.因此,如果你想要退出代码,你应该像这样使用它

my $job_stat = $job->status;print "Exit code ",$job_stat->{exitcode},"\n";

如果您想要工作所用的时间,您可以使用任何或全部

$job_stat->{time}{user}
$job_stat->{time}{kernel}
$job_stat->{time}{elapsed}
总结

以上是内存溢出为你收集整理的perl – 如何知道使用Win32 :: Job启动的进程的状态全部内容,希望文章能够帮你解决perl – 如何知道使用Win32 :: Job启动的进程的状态所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1236403.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存