Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can cause SIGHUP to be generated?

We have about 40 computers running identical hardware and software. They all run Ubuntu 11.10. They all have just one user account to log in. The .profile file is set up to launch a daemon process. The code for the daemon is written in C.

Once in a few weeks, we get a report that the daemon is no longer running. This does not happen on all computers but just one or two. We cannot reproduce the problem consistently.

Looking at the code, the application quits when it receives either SIGHUP or SIGTERM.

As I understand, SIGHUP is generated when a user logs off. In our case, the user never logs off. I am wondering if it is possible that SIGHUP could have been generated for some other reason. Any other thought would be appreciated.

like image 337
Peter Avatar asked Nov 12 '12 02:11

Peter


People also ask

What sends SIGHUP?

SIGHUP would be sent to programs when the serial line was dropped, often because the connected user terminated the connection by hanging up the modem. The system would detect the line was dropped via the lost Data Carrier Detect (DCD) signal.

What is a SIGHUP signal?

The SIGHUP (“hang-up”) signal is used to report that the user's terminal is disconnected, perhaps because a network or telephone connection was broken.

What does SIGHUP received mean?

HANGUP signal received. (562) PROGRESS intercepted a hangup signal (SIGHUP) from UNIX. This indicates that the user's terminal might not be connected. The user is logged out and any active request aborted.

What triggers SIGINT?

The SIGINT signal is sent to a process by its controlling terminal when a user wishes to interrupt the process. This is typically initiated by pressing Ctrl + C , but on some systems, the "delete" character or "break" key can be used. The SIGKILL signal is sent to a process to cause it to terminate immediately (kill).


1 Answers

Well, there are a couple of things to note about SIGHUP. Firstly, its origin is from the concept of a hang-up, i.e. loss of connection to a console over something like a modem. In modern parlance this generally means it has lost its controlling tty. Unless you've taken care to detach from your tty, any program started in a given terminal will receive a SIGHUP when the terminal is closed. See here for details on how to do this in your program. Other options include:

  • running your program inside screen or tmux
  • run your program with nohup or some other daemonising framework

The other possibility is something is deliberately sending your process a SIGHUP which by "tradition" is often used to signal a process that it should re-read its configuration.

like image 147
stsquad Avatar answered Oct 14 '22 08:10

stsquad