0
Windows控制台降级:程序突然无法处理ctrl-c
有一段时间我运行的控制台程序无法处理ctrl-c。示例是cygwin程序,如果我在控制台而不是mintty命令行音频工具中运行它们sox.exe。 我一般型Win-R,cmd,Enter然后启动一个程序。 通常,当您bash在Windows控制台中运行Cygwin shell并按ctrl-c时,它会处理它并重新打印它的提示,但现在它已终止并且我被提示Terminate batch job (Y/N)? 通常,sox.exe响应ctrl-c打印“中止”消息,但现在它崩溃并sox.exe has stopped working显示标准GUI弹出窗口。 此外,如果我从.bat文件中启动一些程序,我还会得到另一个弹出窗口:windows command processor has stopped working 重新启动后,它再次运行。注销/登录或切换用户不起作用。 以下简单程序也在我的机器上崩溃,但同一个二进制文件在另一个上成功: #include "stdafx.h" #include <stdio.h> #include <tchar.h> #include <windows.h> #include <conio.h> static BOOL WINAPI MyHandlerRoutine( _In_ DWORD dwCtrlType ) { switch (dwCtrlType) { case CTRL_C_EVENT: printf("ctrl-c pressed\n"); return TRUE; case CTRL_BREAK_EVENT: printf("ctrl-break …