Originally, SIGBREAK is handled in my program --->
But i found that SIGBREAK is raised when a user logs off from Windows. But it is not expected to be shutdown in this situation.
signal( SIGBREAK, (_SigFunc)handle_interrupts );
void handle_interrupts( int code )
printf( "%d Signal received. Shutting down...\n", code );
fflush( stdout );
logError( "%d Signal received. Shutting down...", code );
bShutdown = 1;
Then i remark it---->
//signal( SIGBREAK, (_SigFunc)handle_interrupts );
Then this problem is solved, but another problem raised:
When user restarts windows during using my program, it is not handled well. Since my program is about TCP/IP, in the above case, the resources cannot be released.
So.......my Q is:
1. Is "ctrl-break" triggered by "windows shutdown"?
2. If so, how can I distinguish "windows shutdown" and "user logs off" when there is a "Ctrl-break" exception?