Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <013201c19812$2125e750$0200a8c0@lifelesswks> From: "Robert Collins" To: "Robert Collins" , References: <00dc01c19758$02b30f10$c51811ac AT brokat DOT de> <1010394535 DOT 566 DOT 10 DOT camel AT lifelesswks> <011401c19762$04185fe0$c51811ac AT brokat DOT de> <000f01c19766$549cb8e0$0200a8c0 AT lifelesswks> <017b01c1976a$21451e70$c51811ac AT brokat DOT de> <007b01c1977d$6093f520$0200a8c0 AT lifelesswks> <20020107165105 DOT GB4652 AT redhat DOT com> <037a01c197cf$1d0a4000$0200a8c0 AT lifelesswks> <20020107234555 DOT GA11984 AT redhat DOT com> <03ca01c197d9$8a16c510$0200a8c0 AT lifelesswks> <20020108002140 DOT GA12820 AT redhat DOT com> <03f001c197dd$7a9bec10$0200a8c0 AT lifelesswks> Subject: Re: bash/cmd CTRL-C problem... Date: Tue, 8 Jan 2002 18:00:16 +1100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-OriginalArrivalTime: 08 Jan 2002 07:00:17.0269 (UTC) FILETIME=[20F2A250:01C19812] 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/