Currently, rubyfmt has no concept of signal handling, and while it's theoretically so fast it shouldn't matter, there are times where it can hang or run for very long times (e.g. running in debug mode on gigantic files) where users may want to kill it. This PR uses the ctrlc crate to just exit when receiving any of SIGINT/SIGTERM/SIGHUP from the OS.
There may be more graceful ways to handle this (like setting a variable and then checking it at certain places in the program), but just exiting gets us 99% of the value here with far less invasive changes.
Resolves #322
Currently,
rubyfmt
has no concept of signal handling, and while it's theoretically so fast it shouldn't matter, there are times where it can hang or run for very long times (e.g. running in debug mode on gigantic files) where users may want to kill it. This PR uses thectrlc
crate to just exit when receiving any ofSIGINT
/SIGTERM
/SIGHUP
from the OS.There may be more graceful ways to handle this (like setting a variable and then checking it at certain places in the program), but just exiting gets us 99% of the value here with far less invasive changes.