Bash, Windows Console programs, and Ctrl-C

Pilhofer, Frank
Fri Jun 3 15:38:00 GMT 2005


I am using Cygwin on Windows 2000.

I am running Win32 command-line programs from bash. In
these programs, I'd like to react to Ctrl-C, using Win32's
SetConsoleCtrlHandler() function.

See, for example, the attached program (compile with MinGW
or MS C++): When pressing Ctrl-C, I expect the program to
continue. For demonstration, it should print "Sleeping ...",
and wait for a while, before exiting.

This works fine when I run the program from a Windows "cmd"
command-line shell.

It does not work when I run the program from Cygwin's bash:
sometimes, I see the "Sleeping" message, but then the program
is interrupted, and never completes cleanly.

This almost looks as if the program is sent a separate signal,
but adding a signal handler (using signal (SIGINT, ...);) does
not make a difference.

"stty intr ^y" also did not have an effect.

Any suggestions?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrlc.cpp
Type: application/octet-stream
Size: 655 bytes
Desc: ctrlc.cpp
URL: <>
-------------- next part --------------
Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list