B
Ben Morrow
Quoth Joost Diepenmaat said:But for the purposes of END blocks, using fork() before an exec() would
allow the END blocks to run anyway:
Sorry, I misunderstood you. Yes, that will work, of course.
# simplified:
END {
# clean up stuff here
# assuming close-on-exec & equivalents are correctly set
}
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).
}
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.
Ben