raptor wrote: > > hi, > > Any idea what the "continuation" will be ?
something like =pod C<Continue> forks the current process and returns, into the child, a coderef which, when run, will wake up the sleeping process and then wait for it to exit, returning its status. In the event that the original code dies, the waiting process (the parent) will get a SIGCHLD and bail out, possibly duplicating some buffered output. =cut sub Continue(){ my $Parent = $$; my $Child = fork; $Child < 0 and die "Continue could not fork: $!"; unless ($Child){ return sub { kill ALRM => $Parent; or die "continuation $Parent not waiting"); waitpid $Parent, 0; }; }else{ local $SIG{CHLD} = sub {exit}; alarm 0; return undef; }; }; only not quite so broad-axed as to what gets kept and what doesn't. Is the above worth putting on CPAN? Is there a way to identify when a parent process ends? Is the semantics of continuations bailing out when the parent dies worth losing the meaning of $$ ? Having the continuation live in the child process certainly is superior to having the continuation live in the parent in all aspects except for death-of-original. Like having Continue append pids to an array and an END { kill TERM <= $_ foreach @Continue::Continuations } in there too... -- David Nicol 816.235.1187 1,3,7-trimethylxanthine