lib/signals: intro Process::kill and Process::signal (fix #180)
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 14 May 2014 17:35:51 +0000 (13:35 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 15 May 2014 19:03:40 +0000 (15:03 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/signals.nit

index 35131d3..7d67bc0 100644 (file)
@@ -144,6 +144,17 @@ redef interface Object
        protected fun set_alarm(sec: Int) `{ alarm(sec); `}
 end
 
+redef class Process
+       # Send a signal to the process
+       fun signal(signal: Int) do native_kill(id, signal)
+
+       # Send the kill signal to the process
+       fun kill do signal(sigkill)
+       
+       # Native implementation of `signal`
+       private fun native_kill(pid, signal: Int) `{ kill(pid, signal); `}
+end
+
 # Hang up detected on controlling terminal or death of controlling process
 protected fun sighup: Int do return 1