Re: BEGIN, INIT etc...
am 30.03.2008 04:07:21 von Joost DiepenmaatBen Morrow
> Quoth Joost Diepenmaat
>> 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/