Ruby: How to make my program a trap and exit the signal correctly?

When I Ctrl C my linux program, I often get output that looks like a stack dump (crash).

Can I catch the Ctrl-C signal and exit gracefully?

Thank!

+3
source share
1 answer

You can capture signals with Kernel.trap:

trap('INT') do
  # exit gracefully
end
+8
source

Source: https://habr.com/ru/post/1743644/


All Articles