Unlike SIGINT it gives no output to console except "terminated". I tried it with testnet and it seemed ok. But is it safe to do so?
(I was wondering about this today... )
From the code, the safest and cleanest way to shut Geth down is using a
SIGINT, either in the form of a CTRL+C, or by sending the signal directly to the process using
kill -INT <pid>. Geth doesn't handle
SIGTERMs in the same, clean way.
SIGHUPs do not lead to graceful shut down.
At various places in the code, Geth registers for notification of interrupt signals (i.e.
sigc := make(chan os.Signal, 1) signal.Notify(sigc, os.Interrupt)
Depending on what Geth is doing, it can then handle
SIGINTs gracefully, for example:
- It can gracefully abort the import of chaindata, by calling
checkInterrupt()before each block of data is imported.
- If the interrupt happens early enough, the node can be shut down before anything meaty has happened at all.
Outside of Geth, there are examples where
SIGTERMs are handled gracefully:
signal(SIGABRT, &ExitHandler::exitHandler); signal(SIGTERM, &ExitHandler::exitHandler); signal(SIGINT, &ExitHandler::exitHandler);