Re: BEGIN, INIT etc...

Ben Morrow <ben [at] morrow.me.uk> writes:

> Quoth Joost Diepenmaat <joost [at] zeekat.nl>:
>> if (! fork()) { # assumin fork() doesn't fail here.
>> exec $whatever;
>> exit;
>
> You need POSIX::_exit here, or the END blocks get run twice (once for
> each process).

Sorry, that's my mistake: exec() never returns, unless it fails, and I
tried to disregard every complication to make the point.

>> }
>> exit;
>
> You probably want to wait here before exitting, as otherwise the execed
> process is orphaned, and your parent gets SIGCHLD early. You probably
> also want to set up signal handlers to pass signals along, etc... see
> the source for the shell of your choice :). Or you could just use
> system, which does all that for you.

Sure, this is just the extremely simplified version :-)


--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Joost Diepenmaat [ So, 30 März 2008 04:07 ] [ ID #1931979 ]
Perl » comp.lang.perl.misc » Re: BEGIN, INIT etc...

Vorheriges Thema: Re: BEGIN, INIT etc...
Nächstes Thema: FAQ 7.26 How can I find out my current package?