Created
April 30, 2009 13:08
-
-
Save thinkerbot/104442 to your computer and use it in GitHub Desktop.
Signals on different platforms.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################### | |
# This is to check what signals are available from the | |
# command line on different platforms. | |
# | |
# === Results | |
# | |
# Mac: | |
# ctrl-T: INFO | |
# ctrl-\: QUIT | |
# ctrl-Z: TSTP | |
# ctrl-C: INT | |
# | |
# Windows: | |
# ctrl-C: INT | |
# | |
# === Note (wikipedia) | |
# SIGINT terminal interrupt Ctrl-C (this causes the process to terminate) | |
# SIGQUIT terminal quit Ctrl-\ (this causes the process to terminate and dump core) | |
# SIGTSTP terminal stop Ctrl-Z (this causes the process to suspend execution) | |
# | |
###################################################### | |
# forbidden to trap on mac | |
forbidden = %w{ | |
SIGVTALRM | |
} | |
Signal.list.each_pair do |key, value| | |
next if forbidden.include?("SIG" + key) | |
Signal.trap(key) do | |
puts "#{key}: #{value}" | |
end | |
end | |
loop do | |
exit if gets.strip == "exit" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment