This is the mail archive of the
mailing list for the Cygwin project.
Re: Can I get a sigint when the bash window closed with close window's button?
- From: Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- To: cygwin at cygwin dot com
- Date: Wed, 16 Nov 2005 11:07:30 +0100
- Subject: Re: Can I get a sigint when the bash window closed with close window's button?
- References: <email@example.com>
Konrad Eisele, le Wed 16 Nov 2005 10:22:43 +0100, a écrit :
> I can get SIGINT when user presses ctrl-c, but when the user
> closes the console by just clicking on the close button then
> no signal handler is called. Neather SIGINT not SIGHUP.
> Maybe it is not possible to get any notification by cygwin
> because cygwin is killed without notification too????
> Can there be a workaround somehow? Maybe there is
> a windows hook or such?
I was looking for such thing some time ago, and couldn't find any useful
« The system generates CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and
CTRL_SHUTDOWN_EVENT signals when the user closes the console, logs off,
or shuts down the system so that the process has an opportunity to clean
up before termination [thanks to SetConsoleCtrlHandler()]. Console
functions, or any C run-time functions that call console functions,
may not work reliably during processing of any of the three signals
mentioned previously. The reason is that some or all of the internal
console cleanup routines may have been called before executing the
process signal handler. »
So when the handler is called, it might already be too late...
Cygwin sets winsup/cygwin/exceptions.cc:ctrl_c_handler() as control
handler, and in the CTRL_CLOSE_EVENT case, returns FALSE, i.e. let
windows terminate the process, even if the user set a signal handler for
SIGHUP. Maybe cygwin could return TRUE in such case, so as to give the
application a chance to detach from the console and continue running?
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html