This is the mail archive of the cygwin@cygwin.com 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]

SetConsoleCtrlHandler problem


Hi,

it appears that Windows binaries won't run correctly under cygwin/bash
if they use SetConsoleCtrlHandler(). I've attached a trivial program
below. If you run this from a Windows console window, it prints
"handler called" every time you hit Ctrl-C. When run from a cygwin bash
window, the program exits after calling the handler with status 130.

Shouldn't the same binary behave identically, regardless of whether
I run it from cygwin/bash or a console window?

I'd appreciate any help to get the Windows behavior for such binaries
under cygwin.

Thanks,

Michi.

#include <Windows.h>
#include <iostream>

static BOOL handler(DWORD sig)
{
    std::cout << "handler called" << std::endl;
    return 1;
}

int main()
{
    SetConsoleCtrlHandler((PHANDLER_ROUTINE)handler, true);
    for(;;)
	;
    return 0;
}



--
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]