Perl文件的EXEC PID [英] EXEC PID for perl files

查看:83
本文介绍了Perl文件的EXEC PID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Perl文件,其中包含exec命令.我想知道是否可以找到该过程的P.I.D ????然后exec命令中有另一个exec命令.那么有什么办法可以让我获得当前正在执行的最新exec(深入)的P.I.D?我正在使用Perl,对其他语言的了解不多,因此,如果您认为它可以工作,请告诉我.

I have a Perl file which has an exec command in it. I was wondering if there is someway I can find the P.I.D of that process??? Then the exec command has another exec command in it. So is there a way I can get the P.I.D of the latest exec (in depth) being executed at the moment? I am using Perl, I don't know much about other languages, so if you think it will work, please let me know.

推荐答案

正如帕维尔所说,PIDexec之后保持不变,因为这基本上用新的(exec呼叫过程未继续!).也就是说,您始终可以通过查看$$来获取您的 PID,例如

As pavel said the PID stays the same after the exec, since this basically replaced the currently running process with the new one (and after the exec the calling process is NOT continued!). That said, you can always get your PID by looking at $$, e.g.

my $pid = $$;
print "My pid is $pid\n";

如果创建一个新的子进程(fork),则将获得该进程的PID作为fork()调用的返回值(在父进程中).

If you create a new child process (fork), then you get the PID of that process as the return value of the fork() call (in the parent process).

希望这对您有帮助, 基督徒

Hope this helps you, Christian

这篇关于Perl文件的EXEC PID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆