Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2011-10-07 17:52:20 +0400
committerChristopher Faylor <me@cgf.cx>2011-10-07 17:52:20 +0400
commit3d1dd0789e32f3c9d99692c79bdfdb8e6e4b4be6 (patch)
treeb8cc6a35d642c38234b6e80622ec7b99566789ba /winsup
parentc53c656b1cfaca0d54de8b310a70270c96ffbb24 (diff)
* fhandler.h (fhandler_console::tc_getpgid): New function.
* spawn.cc (spawn_guts): Add logic to put pure-windows processes "in the background" when they are started that way.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/fhandler.h1
-rw-r--r--winsup/cygwin/spawn.cc12
3 files changed, 19 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 82de82a6e..186f22fa2 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,4 +1,11 @@
2011-10-07 Corinna Vinschen <corinna@vinschen.de>
+ Christopher Faylor <me.cygwin2011@cgf.cx>
+
+ * fhandler.h (fhandler_console::tc_getpgid): New function.
+ * spawn.cc (spawn_guts): Add logic to put pure-windows processes "in
+ the background" when they are started that way.
+
+2011-10-07 Corinna Vinschen <corinna@vinschen.de>
* include/sys/cygwin.h (cygwin_getinfo_types): Define values
additionally as preprocessor symbols.
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 3cbcba91d..be6e012b0 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1100,6 +1100,7 @@ private:
tty_min *tc () const {return &(shared_console_info->tty_min_state);}
public:
+ static pid_t tc_getpgid () {return shared_console_info->tty_min_state.getpgid ();}
fhandler_console (fh_devices);
static console_state *open_shared_console (HWND hw, HANDLE& h)
{
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 37769f78e..40c28f77f 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -558,7 +558,17 @@ spawn_guts (const char *prog_arg, const char *const *argv,
&& (!ch.iscygwin () || mode != _P_OVERLAY
|| cygheap->fdtab.need_fixup_before ()))
c_flags |= CREATE_SUSPENDED;
-
+ /* If a native application should be spawned, we test here if the spawning
+ process is running in a console and, if so, if it's a foreground or
+ background process. If it's a background process, we start the native
+ process with the CREATE_NEW_PROCESS_GROUP flag set. This lets the native
+ process ignore Ctrl-C by default. If we don't do that, pressing Ctrl-C
+ in a console will break native processes running in the background,
+ because the Ctrl-C event is sent to all processes in the console, unless
+ they ignore it explicitely. CREATE_NEW_PROCESS_GROUP does that for us. */
+ if (!ch.iscygwin () && myself->ctty >= 0 && iscons_dev (myself->ctty)
+ && fhandler_console::tc_getpgid () != getpgrp ())
+ c_flags |= CREATE_NEW_PROCESS_GROUP;
ch.refresh_cygheap ();
/* When ruid != euid we create the new process under the current original
account and impersonate in child, this way maintaining the different