If I would like to gracefully stop any background process, which one should I use?
The list of unix signals dates back to the time when computers had serial terminals and modems in which the concept of a control terminal appears. When the modem drops the carrier, the line is suspended.
SIGHUP (1) therefore indicates a loss of connection, causing programs to exit or restart. For daemons such as syslogd and sshd, processes without a terminal connection that should continue to run, SIGHUP is usually a signal that is used to restart or reset.
SIGINT (2) and SIGQUIT (3) literally โbreakโ or โendโ, โfrom the keyboardโ, giving the user immediate control if the program is accelerated. With a terminal with a physical character, this will be the only way to stop the program!
SIGTERM (15) is not related to terminal processing and can only be sent from another process. This will be a normal signal to send to the background process.
source share