This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can I get a sigint when the bash window closed with close window's button?


Hi,

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
hook. And
http://msdn.microsoft.com/library/en-us/dllproc/base/setconsolectrlhandler.asp  says

« 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?

Regards,
Samuel

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]