-
Notifications
You must be signed in to change notification settings - Fork 2
sys.signal
TurtleKitty edited this page May 18, 2019
·
2 revisions
Send and receive POSIX signals.
(proc buddy ()
(proc greeter ()
(say "Hi, buddy!")
(sys.proc.sleep 1)
(greeter))
(proc sulker ()
(sys.proc.sleep 5)
(sulker))
(sys.signal.handle
sys.signal.hup
(proc (s)
(say "HUP? Ha! I laugh at you.")
(greeter)))
(sys.signal.handle
sys.signal.int
(proc (s)
(say "Nyah nyah...")
(greeter)))
(sys.signal.handle
sys.signal.quit
(proc (s)
(say "Still here, buddy!")
(greeter)))
(sys.signal.handle
sys.signal.abrt
(proc (s)
(say "hehehe...")
(greeter)))
(sys.signal.handle
sys.signal.term
(proc (s)
(say
#(text
Aw, man... TERM?
That is cold, buddy.
I ain't talkin to you no more.
))
(sys.signal.mask sys.signal.hup)
(sys.signal.mask sys.signal.int)
(sys.signal.mask sys.signal.quit)
(sys.signal.mask sys.signal.abrt)
(sys.signal.mask sys.signal.term)
(sulker)))
(sys.signal.handle
sys.signal.cont
(proc (s)
(say "YES! I knew you loved me.")
(sys.signal.unmask sys.signal.hup)
(sys.signal.unmask sys.signal.int)
(sys.signal.unmask sys.signal.quit)
(sys.signal.unmask sys.signal.abrt)
(sys.signal.unmask sys.signal.term)
(greeter)))
(say "Buddy handlers online.")
(greeter))
(say "Forking Buddy...")
(def buddy-pid (sys.proc.fork buddy))
(say (cat "Buddy PID: " buddy-pid))
(sys.proc.sleep 3)
(say "HUP")
(sys.signal.send buddy-pid sys.signal.hup)
(sys.proc.sleep 3)
(say "INT")
(sys.signal.send buddy-pid sys.signal.int)
(sys.proc.sleep 3)
(say "QUIT")
(sys.signal.send buddy-pid sys.signal.quit)
(sys.proc.sleep 3)
(say "ABRT")
(sys.signal.send buddy-pid sys.signal.abrt)
(sys.proc.sleep 3)
(say "TERM")
(sys.signal.send buddy-pid sys.signal.term)
(sys.proc.sleep 3)
(say "QUIT")
(sys.signal.send buddy-pid sys.signal.quit)
(sys.proc.sleep 3)
(say "TERM")
(sys.signal.send buddy-pid sys.signal.quit)
(sys.proc.sleep 3)
(say "CONT")
(sys.signal.send buddy-pid sys.signal.cont)
(sys.proc.sleep 3)
(say "STOP")
(sys.signal.send buddy-pid sys.signal.stop)
(sys.proc.sleep 3)
(say "CONT")
(sys.signal.send buddy-pid sys.signal.cont)
(sys.proc.sleep 5)
(say "KILL")
(sys.signal.send buddy-pid sys.signal.kill)
; Forking Buddy...
; Buddy PID: 32498
; Buddy handlers online.
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; HUP
; HUP? Ha! I laugh at you.
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; INT
; Nyah nyah...
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; QUIT
; Still here, buddy!
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; ABRT
; hehehe...
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; TERM
; Aw, man... TERM? That is cold, buddy. I ain't talkin to you no more.
; QUIT
; TERM
; CONT
; YES! I knew you loved me.
; Aw, man... TERM? That is cold, buddy. I ain't talkin to you no more.
; STOP
; CONT
; YES! I knew you loved me.
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; Hi, buddy!
; KILL