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

John McClurkin jwm at nei.nih.gov
Tue Nov 23 20:05:21 CET 2010


William Gordon Rutherdale (rutherw) wrote:
> 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
> 
Instead of signals, why not just place your printing code after 
app.exec() but before the return() in main()?



More information about the Qt-interest-old mailing list