aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/pinfo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index a0419c8..b0f58b4 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -254,6 +254,36 @@ pinfo::set_acl()
debug_printf ("SetKernelObjectSecurity %E");
}
+void
+_pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *fhctty)
+{
+ int initial_ctty = ctty;
+ if ((ctty < 0 || ctty == tc->ntty) && !(flags & O_NOCTTY))
+ {
+ ctty = tc->ntty;
+ syscall_printf ("attached tty%d sid %d, pid %d, tty->pgid %d, tty->sid %d",
+ tc->ntty, sid, pid, pgid, tc->getsid ());
+
+ pinfo p (tc->getsid ());
+ if (sid == pid && (!p || p->pid == pid || !proc_exists (p)))
+ {
+ paranoid_printf ("resetting tty%d sid. Was %d, now %d. pgid was %d, now %d.",
+ tc->ntty, tc->getsid (), sid, tc->getpgid (), pgid);
+ /* We are the session leader */
+ tc->setsid (sid);
+ tc->setpgid (pgid);
+ }
+ else
+ sid = tc->getsid ();
+ if (tc->getpgid () == 0)
+ tc->setpgid (pgid);
+ if (fhctty)
+ cygheap->ctty = *fhctty;
+ else if (initial_ctty < 0)
+ assert (cygheap->ctty.get_io_handle () == NULL);
+ }
+}
+
bool
_pinfo::alive ()
{