summaryrefslogtreecommitdiff
path: root/code/snippets/process_spawn_waitpid.rb
blob: a8b28c4eabc1371aefc4f506aaa4de762cfb0d65 (plain)
1
2
3
4
5
6
7
8
9
10
11
# Do it the blocking way
system 'sleep 5'

# Do it the non-blocking way
Process.spawn 'sleep 5'

# Do it the blocking way with Process.spawn
# Notice that it returns the pid of the child process
pid = Process.spawn 'sleep 5'
Process.waitpid(pid)