Re: BEGIN, INIT etc...
- From: Joost Diepenmaat <joost@xxxxxxxxx>
- Date: Sun, 30 Mar 2008 04:07:21 +0200
Ben Morrow <ben@xxxxxxxxxxxx> writes:
Quoth Joost Diepenmaat <joost@xxxxxxxxx>:
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/
.
- References:
- BEGIN, INIT etc...
- From: pgodfrin
- Re: BEGIN, INIT etc...
- From: Joost Diepenmaat
- Re: BEGIN, INIT etc...
- From: Ben Morrow
- Re: BEGIN, INIT etc...
- From: Joost Diepenmaat
- Re: BEGIN, INIT etc...
- From: Ben Morrow
- BEGIN, INIT etc...
- Prev by Date: Re: BEGIN, INIT etc...
- Next by Date: Re: BEGIN, INIT etc...
- Previous by thread: Re: BEGIN, INIT etc...
- Next by thread: Re: BEGIN, INIT etc...
- Index(es):
Relevant Pages
|
|