diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 98049f48c..b854c378b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +2010-09-20 Christopher Faylor + + * 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 * fhandler_tty.cc (fhandler_tty_slave::init): Add additional checks to diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 632e3aaf0..52b264a7d 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -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) diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 37700a6e1..37a74513c 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -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. */ diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index e12f63e2d..615104e80 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -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); } diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index cef4db81c..2005592f7 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -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");