windowswinapiposixshutdownsigterm

Win32 API analog of sending/catching SIGTERM


Under POSIX OS there is signal API that allows to send a signal to process to shut it down with kill and you can catch it with sigaction and do what you need;

However, Win32 is not POSIX system, so:

I'm not talking about GUI, I'm talking about TCP/IP server that should be nicely shutdown. that does not run like windows service.


Solution

  • You get a WM_QUIT message on your first created thread.

    When you don't handle that, your process is forcibly shutdown.

    So just implement a message queue in your first thread, which looks for the WM_QUIT message