* 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.
This commit is contained in:
Christopher Faylor 2012-01-08 06:24:17 +00:00
parent 04243e461d
commit a345dc55f9
5 changed files with 32 additions and 33 deletions

View File

@ -1,3 +1,16 @@
2012-01-08 Christopher Faylor <me.cygwin2011@cgf.cx>
* 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.
2012-01-06 Yaakov Selkowitz <yselkowitz@users.sourceforge.net> 2012-01-06 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* cygwin.din (pthread_sigqueue): Export. * cygwin.din (pthread_sigqueue): Export.

View File

@ -149,14 +149,10 @@ dtable::get_debugger_info ()
void void
dtable::stdio_init () dtable::stdio_init ()
{ {
/* Set these before trying to output anything from strace.
Also, always set them even if we're to pick up our parent's fds
in case they're missed. */
if (myself->cygstarted || ISSTATE (myself, PID_CYGPARENT)) if (myself->cygstarted || ISSTATE (myself, PID_CYGPARENT))
{ {
tty_min *t = cygwin_shared->tty.get_cttyp (); tty_min *t = cygwin_shared->tty.get_cttyp ();
if (t && t->getpgid () == myself->pid && t->is_console) if (t && t->is_console)
init_console_handler (true); init_console_handler (true);
return; return;
} }

View File

@ -62,7 +62,7 @@ fhandler_termios::tcinit (bool is_pty_master)
int int
fhandler_termios::tcsetpgrp (const pid_t pgid) fhandler_termios::tcsetpgrp (const pid_t pgid)
{ {
termios_printf ("tty %d pgid %d, sid %d, tsid %d", tc ()->ntty, pgid, termios_printf ("%s, pgid %d, sid %d, tsid %d", tc ()->ttyname (), pgid,
myself->sid, tc ()->getsid ()); myself->sid, tc ()->getsid ());
if (myself->sid != tc ()->getsid ()) if (myself->sid != tc ()->getsid ())
{ {
@ -168,8 +168,8 @@ fhandler_termios::bg_check (int sig)
if (sig < 0) if (sig < 0)
sig = -sig; sig = -sig;
termios_printf ("bg I/O pgid %d, tpgid %d, %s, ntty %s", myself->pgid, tc ()->getpgid (), termios_printf ("%s, bg I/O pgid %d, tpgid %d, myctty %s", tc ()->ttyname (),
myctty (), tc ()->ttyname ()); myself->pgid, tc ()->getpgid (), myctty ());
if (tc ()->getsid () == 0) if (tc ()->getsid () == 0)
{ {

View File

@ -433,9 +433,6 @@ _pinfo::_ctty (char *buf)
bool bool
_pinfo::set_ctty (fhandler_termios *fh, int flags) _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 (); 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); 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)) 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", syscall_printf ("attaching %s sid %d, pid %d, pgid %d, tty->pgid %d, tty->sid %d",
__ctty (), sid, pid, pgid, tc.getpgid (), tc.getsid ()); __ctty (), sid, pid, pgid, tc.getpgid (), tc.getsid ());
if (!cygwin_finished_initializing && !myself->cygstarted if (!cygwin_finished_initializing && !myself->cygstarted
&& myself->pgid == myself->pid && tc.getpgid () && tc.getsid ()) && pgid == pid && tc.getpgid () && tc.getsid ())
{ {
myself->pgid = tc.getpgid (); pgid = tc.getpgid ();
myself->sid = tc.getsid ();
} }
pinfo p (tc.getsid ()); /* May actually need to do this:
if (sid == pid && (!p || p->pid == pid || !p->exists ()))
{ if (sid == pid && !tc.getsid () || !procinfo (tc.getsid ())->exists)
#ifdef DEBUGGING
debug_printf ("resetting %s sid. Was %d, now %d. pgid was %d, now %d.", but testing for process existence is expensive so we avoid it until
__ctty (), tc.getsid (), sid, tc.getpgid (), pgid); an obvious bug surfaces. */
#else if (sid == pid && !tc.getsid ())
paranoid_printf ("resetting %s sid. Was %d, now %d. pgid was %d, now %d.", tc.setsid (sid);
__ctty (), tc.getsid (), sid, tc.getpgid (), pgid); sid = tc.getsid ();
#endif /* See above */
/* We are the session leader */ if (!tc.getpgid () && pgid == pid)
tc.setsid (sid); tc.setpgid (pgid);
tc.setpgid (pgid);
}
else
sid = tc.getsid ();
if (tc.getpgid () == 0)
tc.setpgid (pgid);
} }
debug_printf ("cygheap->ctty now %p, archetype %p", cygheap->ctty, fh->archetype); debug_printf ("cygheap->ctty now %p, archetype %p", cygheap->ctty, fh->archetype);
return ctty > 0; return ctty > 0;

View File

@ -269,7 +269,7 @@ do_cleanup (void *args)
# undef cleanup # undef cleanup
} }
NO_COPY child_info_spawn ch_spawn; child_info_spawn NO_COPY ch_spawn;
int int
child_info_spawn::worker (const char *prog_arg, const char *const *argv, child_info_spawn::worker (const char *prog_arg, const char *const *argv,