Mail Archives: cygwin/2002/01/08/02:01:38
FWIW this patch (Chris where should I put the in_stub declaration)
====
Index: exceptions.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/exceptions.cc,v
retrieving revision 1.103
diff -u -p -r1.103 exceptions.cc
--- exceptions.cc 2002/01/05 22:25:34 1.103
+++ exceptions.cc 2002/01/08 06:54:23
@@ -890,11 +890,14 @@ setup_handler (int sig, void *handler, s
#error "Need to supply machine dependent setup_handler"
#endif
+// Yeah, well. Where to put this?
+bool in_stub = false;
+
/* CGF Keyboard interrupt handler. */
static BOOL WINAPI
ctrl_c_handler (DWORD type)
{
- if (type == CTRL_LOGOFF_EVENT)
+ if (type == CTRL_LOGOFF_EVENT || (type == CTRL_C_EVENT && in_stub ==
true))
return TRUE;
/* Return FALSE to prevent an "End task" dialog box from appearing
Index: spawn.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/spawn.cc,v
retrieving revision 1.94
diff -u -p -r1.94 spawn.cc
--- spawn.cc 2001/11/05 06:09:08 1.94
+++ spawn.cc 2002/01/08 06:54:25
@@ -314,6 +314,9 @@ av::unshift (const char *what, int conv)
return 1;
}
+// From exceptions.cc
+extern bool in_stub; // indicate when we are wrapping a non-cygwin
program
+
static int __stdcall
spawn_guts (HANDLE hToken, const char * prog_arg, const char *const
*argv,
const char *const envp[], int mode)
@@ -804,8 +807,10 @@ spawn_guts (HANDLE hToken, const char *
MALLOC_CHECK;
if (mode == _P_OVERLAY)
{
+ in_stub = true; // don't close on CTRL C.
int nwait = 3;
HANDLE waitbuf[3] = {pi.hProcess, signal_arrived, spr};
+ // If spr is not triggered, it's not a cygwin process ?
for (int i = 0; i < 100; i++)
{
switch (WaitForMultipleObjects (nwait, waitbuf, FALSE,
INFINITE))
@@ -823,6 +828,7 @@ spawn_guts (HANDLE hToken, const char *
reset_signal_arrived ();
continue;
case WAIT_OBJECT_0 + 2:
+ // SPR
if (myself->ppid_handle)
res |= EXIT_REPARENTING;
if (!my_parent_is_alive ())
@@ -847,6 +853,7 @@ spawn_guts (HANDLE hToken, const char *
}
break;
}
+
ForceCloseHandle (spr);
@@ -874,6 +881,8 @@ spawn_guts (HANDLE hToken, const char *
system_printf ("old hProcess %p, hProcess %p", oldh,
myself->hProcess);
}
}
+ in_stub = false; // We're safely reparented now, or a cygwin
wrapped win32
+ // program has terminated.
}
====
means that I get this output from the test programs:
=============
Administrator AT LIFELESSWKS ~/t
$ ./signals.exe
>>> signals: Waiting now...
>>>>>> myclass CPP: Installing atexit handler...
>>>>>> myclass CPP: Installing signal handler...
>>>>>> myclass CPP: Falling asleep...
............................................................
>>> signals: Signal SIGINT=2 received
......................................
>>> signals: Finished waiting now...
>>> signals: Forwarding CTRL_BREAK_EVENT to the child process...
..
>>>>>> myclass CPP: SIGBREAK caught...
>>>>>> myclass CPP: Process terminating...
=================
So it looks like it solves it. I've noticed no side effects either.
Rob
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -