OSDN Git Service

* include/sys/cygwin.h (PID_NOTCYGWIN): New enum.
authorcgf <cgf>
Mon, 20 Sep 2010 22:28:55 +0000 (22:28 +0000)
committercgf <cgf>
Mon, 20 Sep 2010 22:28:55 +0000 (22:28 +0000)
* spawn.cc (spawn_guts): Set a flag when a process is not a cygwin process.
* fhandler_tty.cc (fhandler_tty_slave::init): Remove previous change.  Try a
different method to determine when we should become the process group owner.
* signal.cc (kill0): Remove archaic code which dealt with never-set flag.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/signal.cc
winsup/cygwin/spawn.cc

index 98049f4..b854c37 100644 (file)
@@ -1,5 +1,16 @@
 2010-09-20  Christopher Faylor  <me+cygwin@cgf.cx>
 
+       * include/sys/cygwin.h (PID_NOTCYGWIN): New enum.
+       * spawn.cc (spawn_guts): Set a flag when a process is not a cygwin
+       process.
+       * fhandler_tty.cc (fhandler_tty_slave::init): Remove previous change.
+       Try a different method to determine when we should become the process
+       group owner.
+       * signal.cc (kill0): Remove archaic code which dealt with never-set
+       flag.
+
+2010-09-20  Christopher Faylor  <me+cygwin@cgf.cx>
+
        * fhandler_tty.cc (fhandler_tty_slave::init): Add additional checks to
        determine when a process should grab control of a tty's pgid.  Use
        being_debugged() for consistency.
index 632e3aa..52b264a 100644 (file)
@@ -711,19 +711,19 @@ fhandler_tty_slave::init (HANDLE f, DWORD a, mode_t)
 
   int ret = open (flags);
 
-  /* We should only grab this when the parent process owns the pgid
-  (which could happen when a cygwin process starts a DOS process which
-  starts a cygwin process or when we are being started directly from a
-  windows process, e.g., from the CMD prompt.  */
-  if (ret && !cygwin_finished_initializing && !being_debugged ()
-      && (myself->ppid == 1 || myself->ppid == tc->getpgid ()))
+  if (ret && !cygwin_finished_initializing && !being_debugged ())
     {
       /* This only occurs when called from dtable::init_std_file_from_handle
         We have been started from a non-Cygwin process.  So we should become
         tty process group leader.
         TODO: Investigate how SIGTTIN should be handled with pure-windows
         programs. */
-      tc->setpgid (myself->pgid);
+      pinfo p (tc->getpgid ());
+      /* We should only grab this when the process group owner for this
+        tty is a non-cygwin process or we've been started directly
+        from a non-Cygwin process with no Cygwin ancestry.  */
+      if (!p || ISSTATE (p, PID_NOTCYGWIN))
+       tc->setpgid (myself->pgid);
     }
 
   if (f != INVALID_HANDLE_VALUE)
index 37700a6..37a7451 100644 (file)
@@ -155,6 +155,7 @@ enum
   PID_STOPPED         = 0x00004, /* Waiting for SIGCONT. */
   PID_TTYIN           = 0x00008, /* Waiting for terminal input. */
   PID_TTYOU           = 0x00010, /* Waiting for terminal output. */
+  PID_NOTCYGWIN               = 0x00080, /* Set if process is not a cygwin app. */
   PID_ORPHANED        = 0x00020, /* Member of an orphaned process group. */
   PID_ACTIVE          = 0x00040, /* Pid accepts signals. */
   PID_CYGPARENT               = 0x00080, /* Set if parent was a cygwin app. */
index e12f63e..615104e 100644 (file)
@@ -274,12 +274,6 @@ kill0 (pid_t pid, siginfo_t& si)
       return -1;
     }
 
-  /* Silently ignore stop signals from a member of orphaned process group.
-     FIXME: Why??? */
-  if (ISSTATE (myself, PID_ORPHANED) &&
-      (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU))
-    si.si_signo = 0;
-
   return (pid > 0) ? pinfo (pid)->kill (si) : kill_pgrp (-pid, si);
 }
 
index cef4db8..2005592 100644 (file)
@@ -548,8 +548,9 @@ loop:
 
   PWCHAR cwd;
   cwd = NULL;
-  if (!real_path.iscygexec())
+  if (!real_path.iscygexec ())
     {
+      myself->process_state |= PID_NOTCYGWIN;
       cygheap->cwd.cwd_lock.acquire ();
       cwd = cygheap->cwd.win32.Buffer;
     }
@@ -727,7 +728,8 @@ loop:
     {
       myself->set_has_pgid_children ();
       ProtectHandle (pi.hThread);
-      pinfo child (cygpid, PID_IN_USE);
+      pinfo child (cygpid,
+                  PID_IN_USE | (real_path.iscygexec () ? 0 : PID_NOTCYGWIN));
       if (!child)
        {
          syscall_printf ("pinfo failed");