-
-
Save anonymous/eb0558b216a97f383c2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# * * * | |
# somewhere at startup | |
# * * * | |
$SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) {} }; | |
# * * * | |
# somewhere in the code | |
# * * * | |
use POSIX; | |
sub job { | |
my ($job) = @_; | |
unless (fork()) { | |
my $exit = 0; | |
unless (eval { $job->(); 1 })) { | |
$exit = 1; | |
} | |
POSIX::_exit($exit); | |
} | |
} | |
job(sub { say "hello world from child process (pid $$)" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment