Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use CTRL-C, 'n' and 'q' keyboard commands in Cygwin and Msys2 shells #112

Closed
johnoel opened this issue Jul 12, 2019 · 3 comments
Closed

Comments

@johnoel
Copy link
Contributor

johnoel commented Jul 12, 2019

No description provided.

@iantaylor-NOAA
Copy link

This block of code seems to only be implemented for Microsoft Visual C, but I don't know the history of that:

#ifdef _MSC_VER
BOOL CtrlHandler(DWORD fdwCtrlType)
{
if (fdwCtrlType == CTRL_C_EVENT)
{
//Should exit if CTRL_C_EVENT occurs again.
if (ctlc_flag) ad_exit(1);
ctlc_flag = 1;
if (ad_printf)
(*ad_printf)("\npress q to quit or c to invoke derivative checker: ");
return true;
}
return false;
}
#else
extern "C" void onintr(int k)
{
signal(SIGINT, exit_handler);
ctlc_flag = 1;
if (ad_printf)
(*ad_printf)("\npress q to quit or c to invoke derivative checker"
" or s to stop optimizing: ");
}
#endif

johnoel added a commit that referenced this issue Jul 12, 2019
@johnoel
Copy link
Contributor Author

johnoel commented Jul 12, 2019

Yes, it should be defined for Windows.

johnoel added a commit that referenced this issue Jul 19, 2019
This reverts commit d7daf20.
@johnoel
Copy link
Contributor Author

johnoel commented Jul 20, 2019

If you are using cygwin or msys2 shell, it uses mintty in the terminal which
does not correctly pass ctrl-c to the executable.

To workaround it, prefix winpty to run the program.

ie

$ winpty ./n2mvol.exe

Ctrl-C should now work.

The other alternative is to run the program using the stock Windows Command Prompt.

There is no solution for fixing this within admb, it is an issue with the shell.

mintty/mintty#684

@johnoel johnoel changed the title MinGW ignores 'n' and 'q' keyboard commands Unable to use CTRL-C, 'n' and 'q' keyboard commands in Cygwin and Msys2 shells Jul 20, 2019
@johnoel johnoel closed this as completed Jul 24, 2019
johnoel added a commit that referenced this issue Jul 31, 2019
This reverts commit d7daf20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants