Created
November 7, 2012 15:44
-
-
Save chrismo/4032347 to your computer and use it in GitHub Desktop.
Using at_exit with fork
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
child = fork do | |
at_exit { $stderr.puts "Child one is done." } | |
exit # superfluous | |
end | |
Process.wait | |
$stderr.puts "Parent is done waiting for child one #{child}." | |
child = fork do | |
at_exit { $stderr.puts "This won't get hit." } | |
exit! | |
end | |
Process.wait | |
$stderr.puts "Parent is done waiting for child two #{child}." | |
at_exit { $stderr.puts "Parent registered at_exit forked into child. #{Process.pid}"} | |
child = fork do | |
exit # superfluous | |
end | |
Process.wait | |
$stderr.puts "Parent is done waiting for child three #{child}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment