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
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-01-08 10:24:17 +0400
committerChristopher Faylor <me@cgf.cx>2012-01-08 10:24:17 +0400
commita345dc55f9d6ea302ec7bfbb0bda96cf20da80dd (patch)
tree93fe4f45e9ab80c5e2612a3ef963377cadbe8abc /winsup/cygwin/pinfo.cc
parent04243e461d1101477a2b0de259529b1e9249f917 (diff)
* dtable.cc (dtable::stdio_init): Always initialize console when we have one.
* fhandler_termios.cc (fhandler_termios::tcsetpgrp): Use a better method to print tty name for debugging. (fhandler_termios::bg_check): Ditto. * pinfo.cc (_pinfo::set_ctty): Remove leftover debugging stuff. Simplify behavior when setting tty's sid and pgid to avoid overwriting previously set values. * spawn.cc (ch_spawn): Cosmetic change.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc38
1 files changed, 14 insertions, 24 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 7affe4150..65640b2c9 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -433,9 +433,6 @@ _pinfo::_ctty (char *buf)
bool
_pinfo::set_ctty (fhandler_termios *fh, int flags)
{
-debug_printf ("fh %p", fh);
-debug_printf ("tc %p", fh->tc ());
-if (!this || !fh->tc ()) try_to_debug ();
tty_min& tc = *fh->tc ();
debug_printf ("old %s, ctty device number %p, tc.ntty device number %p flags & O_NOCTTY %p", __ctty (), ctty, tc.ntty, flags & O_NOCTTY);
if (fh && &tc && (ctty <= 0 || ctty == tc.ntty) && !(flags & O_NOCTTY))
@@ -466,30 +463,23 @@ if (!this || !fh->tc ()) try_to_debug ();
syscall_printf ("attaching %s sid %d, pid %d, pgid %d, tty->pgid %d, tty->sid %d",
__ctty (), sid, pid, pgid, tc.getpgid (), tc.getsid ());
if (!cygwin_finished_initializing && !myself->cygstarted
- && myself->pgid == myself->pid && tc.getpgid () && tc.getsid ())
+ && pgid == pid && tc.getpgid () && tc.getsid ())
{
- myself->pgid = tc.getpgid ();
- myself->sid = tc.getsid ();
+ pgid = tc.getpgid ();
}
- pinfo p (tc.getsid ());
- if (sid == pid && (!p || p->pid == pid || !p->exists ()))
- {
-#ifdef DEBUGGING
- debug_printf ("resetting %s sid. Was %d, now %d. pgid was %d, now %d.",
- __ctty (), tc.getsid (), sid, tc.getpgid (), pgid);
-#else
- paranoid_printf ("resetting %s sid. Was %d, now %d. pgid was %d, now %d.",
- __ctty (), tc.getsid (), sid, tc.getpgid (), pgid);
-#endif
- /* We are the session leader */
- tc.setsid (sid);
- tc.setpgid (pgid);
- }
- else
- sid = tc.getsid ();
- if (tc.getpgid () == 0)
- tc.setpgid (pgid);
+ /* May actually need to do this:
+
+ if (sid == pid && !tc.getsid () || !procinfo (tc.getsid ())->exists)
+
+ but testing for process existence is expensive so we avoid it until
+ an obvious bug surfaces. */
+ if (sid == pid && !tc.getsid ())
+ tc.setsid (sid);
+ sid = tc.getsid ();
+ /* See above */
+ if (!tc.getpgid () && pgid == pid)
+ tc.setpgid (pgid);
}
debug_printf ("cygheap->ctty now %p, archetype %p", cygheap->ctty, fh->archetype);
return ctty > 0;