SetConsoleCtrlHandler does not get called on shutdown
问题 I wrote an application that runs in a console and needs to do a quick backup before the system shuts down or the user logs out. My test application writes a file with the signal and works when the console window is closed by hand (click on the X). But it does not work when the console is closed on shutdown or logout. From what I have read on MSDN, this should work. The program was compiled using cygwin64, could this be the problem? #include <windows.h> #include <stdio.h> #include <stdlib.h>