Last active
August 28, 2020 08:48
-
-
Save benoittgt/a8cdfb07845754774b9469de2201885b to your computer and use it in GitHub Desktop.
Playing with child process in Ruby
This file contains hidden or 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
| pid = Process.pid | |
| puts "Current process pid : #{pid}" | |
| child_pids = [] | |
| 6.times.each do |i| | |
| child_pids << Process.fork do | |
| Process.setproctitle("ruby childp n #{i} with #{i * 3}s") | |
| puts "sleeping #{i * 3}s"; sleep i * 3 | |
| end | |
| end | |
| p Process.waitall | |
| puts "Done" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will print with
while true; do pstree -s ruby; sleep 0.5; clear; done