Use Process.kill : Process « Development « Ruby

Use Process.kill

Process.kill(1,pid1)         # Send signal 1 to process pid1
Process.kill("HUP",pid2)     # Send SIGHUP to pid2
Process.kill("SIGHUP",pid2)  # Send SIGHUP to pid3
Process.kill("SIGHUP",0)     # Send SIGHUP to self

trap(1) { puts "Caught signal 1" }
sleep 2
Process.kill(1,0)  # Send to self


Related examples in the same category

1.use Process.wait to wait for all child processes to finish before continuing.
2.Daemon Processes and Process.ppid