From 05c98e076e3810a8168d668bde0862900e749467 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 21 Apr 2010 19:36:40 +0000 Subject: [PATCH] * fhandler_termios.cc (tcinit): Remove previously applied change. Replace with... * fhandler_tty.cc (fhandler_tty_slave::init): Become process group leader if called from dtable::init_std_file_from_handle. Add comment to explain. --- winsup/cygwin/ChangeLog | 9 +++++++++ winsup/cygwin/fhandler_termios.cc | 11 ++--------- winsup/cygwin/fhandler_tty.cc | 9 +++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c0f9da6d6..f59f4e914 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2010-04-21 Corinna Vinschen + Christopher Faylor + + * fhandler_termios.cc (tcinit): Remove previously applied change. + Replace with... + * fhandler_tty.cc (fhandler_tty_slave::init): Become process group + leader if called from dtable::init_std_file_from_handle. Add comment + to explain. + 2010-04-21 Corinna Vinschen * dtable.cc (dtable::init_std_file_from_handle): Set access mask for diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index b7f7860c5..0f27a9838 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -1,7 +1,7 @@ /* fhandler_termios.cc - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 - Red Hat, Inc. + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, + 2010 Red Hat, Inc. This file is part of Cygwin. @@ -58,13 +58,6 @@ fhandler_termios::tcinit (tty_min *this_tc, bool force) tc->pgid = myself->pgid; tc->initialized (true); } - else if (myself->ppid == 1 && myself->pid == myself->pgid - && myself->pgid == myself->sid) - /* We have been started from a non-Cygwin process. So we just become - tty process group leader. - TODO: Investigate how SIGTTIN should be handled with pure-windows - programs. */ - tc->pgid = myself->pgid; } int diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 734fef2a9..77205ea6e 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -719,6 +719,15 @@ fhandler_tty_slave::init (HANDLE f, DWORD a, mode_t) flags = O_RDWR; int ret = open (flags); + if (ret && !cygwin_finished_initializing) + { + /* 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->pgid = myself->pgid; + } if (f != INVALID_HANDLE_VALUE) CloseHandle (f); /* Reopened by open */