diff options
| author | mo khan <mo@mokhan.ca> | 2021-02-08 10:18:07 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2021-02-08 10:18:07 -0700 |
| commit | 5c420f26a447501884f1bfa2dee838cc75bdf7b7 (patch) | |
| tree | 872eff766293d1aa432536044a41201638bc8b18 /lib/sigtrap.rb | |
| parent | 8a3baed5a50d724046aee329d7e1271902d2368d (diff) | |
answer question 1 in assignment 1
Diffstat (limited to 'lib/sigtrap.rb')
| -rw-r--r-- | lib/sigtrap.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sigtrap.rb b/lib/sigtrap.rb new file mode 100644 index 0000000..3d80121 --- /dev/null +++ b/lib/sigtrap.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +pid = fork do + Signal.trap("USR1") do + puts "done" + exit 0 + end + + loop do + print "." + sleep 1 + end +end + +Process.detach(pid) +sleep 5 +Process.kill("USR1", pid) |
