[Qt-interest] No POSIX Signals in Windows; How To Capture Program Termination

William Gordon Rutherdale (rutherw) rutherw at cisco.com
Tue Nov 23 19:45:39 CET 2010


Hi.

I have written a program using QCoreApplication that I want to work
portably across both Linux and Windows.

I added a feature to print information such as statistics when the
program terminates.  I got this working in Linux by creating a handler
for SIGINT/SIGTERM/SIGHUP that posts an event.

Now, when I moved the source code to my Qt installation in Windows, I
couldn't get it to compile.  Qt sits on top of mingw, which apparently
doesn't support POSIX process semantics.  So the compile-time error I
got right away was that SIGHUP is an undefined symbol.

My question:  How can I write Qt code that detects imminent shutdown in
a similar fashion in Windows?

Any help would be appreciated.

-Will





More information about the Qt-interest-old mailing list