Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created April 30, 2009 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkerbot/104442 to your computer and use it in GitHub Desktop.
Save thinkerbot/104442 to your computer and use it in GitHub Desktop.
Signals on different platforms.
######################################################
# 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