开发者

Can't find the process after invoking this Perl script in shell

t:

#!/usr/bin/perl

exec("perl -Ilib -d" . $ARGV[0]);

It's invoked as t perl_script.

But after that I can't find it by ps,and can't terminate it by ^C

What's wron开发者_开发知识库g ?


http://perldoc.perl.org/functions/exec.html

You're exec'ing perl with the args and perl_script you pass in. This means the current script t ceases to exist and is replaced by perl -Ilib -dperl_script.

The process you're looking for with ps will be the one you passed in (perl_script)

Edit for comment from OP below:

The actual process is perl since that's what you exec'd, but you can certainly find it via the perl_script you passed in using grep:

$ ps -ef |grep perl_script
broach   13039  2264  0 01:08 pts/0    00:00:00 perl -Ilib -dperl_script


Do you need to include a space after -d? Otherwise you are exec'ing

perl -Ilib -dperl_script

instead of

perl -Ilib -d perl_script

Cleaner still:

exec("perl","-Ilib","-d",$ARGV[0]);
exec($^X, "-Ilib", "-d", $ARGV[0]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜