If I terminate the Xorg server with a SIGINT signal (eg. when I press Ctrl+C), what signal does it send to its clients?
1 Answer
The X server doesn't send a signal to its clients. This wouldn't be possible in general since the client and the server might not even be running on the same machine.
Communication between the server and the client goes through a socket. When the server dies, its end of the socket is closed. It's up to the client application to decide how to react to that; most print an error message and terminate.
If the client is a terminal emulator, then when it terminates, it sends SIGHUP to its controlling process, which is usually a shell. The shell in turn sends SIGHUP to the main process of each foreground or background job.
- Thank you, I was curious about this because I had a running
makejob in an X terminal emulator.makecan only do a cleanup of half-ready binaries if it can catch a signal eg.SIGHUP. So it is safe to terminate X ifmakeis running in an X terminal if I got it right becausemakewill receiveSIGHUP.psimon– psimon2014-06-20 06:56:10 +00:00Commented Jun 20, 2014 at 6:56 - 1@psimon Yes,
makewill receive SIGHUP. But you may want to runmakeinside screen or tmux instead, so that it keeps running and you can reconnect to the session even if X dies.Gilles 'SO- stop being evil'– Gilles 'SO- stop being evil'2014-06-20 07:18:43 +00:00Commented Jun 20, 2014 at 7:18 - Yes, I regularly use
screen, but in this specific case I forgot to use it (an automatic upgrade script handles the kernel upgrade on my security server, which is still experimental) and a mistyped command on a tty killed Xorg. I'm building this kernel image on an old P3 and it was running for two days, so I wanted to make sure that I can resume.psimon– psimon2014-06-20 07:24:12 +00:00Commented Jun 20, 2014 at 7:24