diff options
Diffstat (limited to 'code/snippets/process_spawn_waitpid.rb')
| -rw-r--r-- | code/snippets/process_spawn_waitpid.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/code/snippets/process_spawn_waitpid.rb b/code/snippets/process_spawn_waitpid.rb new file mode 100644 index 0000000..a8b28c4 --- /dev/null +++ b/code/snippets/process_spawn_waitpid.rb @@ -0,0 +1,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) + |
