[Interest] proper (silent) exit in response to SIGHUP?

Thiago Macieira thiago.macieira at intel.com
Mon Oct 8 17:37:46 CEST 2018

On Monday, 8 October 2018 00:50:50 PDT René J.V. Bertin wrote:
> Thiago Macieira wrote:
> That sounds real easy indeed ;)
> > Create a QSocketNotifier on the reading end of the pipe or on the eventfd,
> > connect its activation signal to a slot that does what you want.
> What is the purpose of the pipe/eventfd detour? Can't I just call a function
> or signal a slot directly?

You can call _exit. You can't call much else. You can only call the functions 
listed in this man page from a signal handler:

NEVER allocate memory and NEVER lock a mutex in a signal handler.

> > Exiting with exit() is not expected to work with Qt. Normal exit must
> > return from main(), so you should simply ask the QCoreApplication main
> > event loop to exit (quit() slot).
> A KDE dev told me a SIGHUP should already work (contrary to my experience).
> So I tried it on a complex app running locally and it turns out that it
> indeed went through its regular shut-down cycle. Including unsaved file
> alerts.

That might be a KF5 add-on. Qt doesn't do that by itself.

> This sort of YMMV is why I didn't wonder aloud why Qt doesn't attempt to
> catch SIGHUP itself, to invoke QCoreApplication::quit.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Interest mailing list