Created
September 24, 2011 21:32
-
-
Save cwgem/1239892 to your computer and use it in GitHub Desktop.
Simple Fork Example
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
# Parent process | |
3.times do | |
fork do | |
# child process logic here | |
trap('INT') { exit } | |
loop { puts "Hello from #$$"; sleep 3 } | |
# end child process logic | |
end | |
end | |
# Parent process logic continues | |
trap('INT') { exit } | |
Process.waitall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment