[PATCH v2] Cygwin: pinfo: Fix exit code when non-cygwin app exits by Ctrl-C.
Takashi Yano
takashi.yano@nifty.ne.jp
Thu Feb 24 14:24:29 GMT 2022
- Previously, if non-cygwin app exits by Ctrl-C, exit code was
0x00007f00. With this patch, the exit code will be 0x00000002,
which means process exited by SIGINT.
---
winsup/cygwin/exceptions.cc | 6 +++++-
winsup/cygwin/pinfo.cc | 3 +++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 73bf68939..f6a755b3c 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1139,7 +1139,11 @@ ctrl_c_handler (DWORD type)
}
if (ch_spawn.set_saw_ctrl_c ())
- return TRUE;
+ {
+ if (myself->process_state & PID_NOTCYGWIN)
+ sigExeced = SIGINT;
+ return TRUE;
+ }
/* We're only the process group leader when we have a valid pinfo structure.
If we don't have one, then the parent "stub" will handle the signal. */
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index bce743bfc..bb7c16547 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -156,6 +156,9 @@ pinfo::status_exit (DWORD x)
a lengthy small_printf instead. */
x = SIGBUS;
break;
+ case STATUS_CONTROL_C_EXIT:
+ x = SIGINT;
+ break;
default:
debug_printf ("*** STATUS_%y\n", x);
x = 127 << 8;
--
2.35.1
More information about the Cygwin-patches
mailing list