且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

fork + exec +调用方不应等待子进程

更新时间:2022-06-01 04:26:01

而不是在script_a中使用``.我们已经在script_a中重定向了STDOUT和STDERR. 像

Instead of using `` in script_a. We have redirected the STDOUT and STDERR in script_a. Something like

script_a

system("script_b.pl > /var/tmp/out_file 2>&1");

script_b

#! /usr/local/bin/perl

$f_id = fork();

if (! $f_id) {
    exec("sleep 10; echo 'i am child'");
}

if ($f_id) {
    print "i am parent\n";
}

通过这种方式,调用方不必等待exec中的孩子完成.

This way the caller didnot wait for the child in exec to complete.

感谢您的帮助.