summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fork.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-12-30 01:57:16 +0000
committerChristopher Faylor <me@cgf.cx>2003-12-30 01:57:16 +0000
commit8ed5c9b6297dce0115a462e6ae1a644a9a278bdb (patch)
tree473e2145a60c105c2375886d95fe3c675220af25 /winsup/cygwin/fork.cc
parente97377932b06f0993df95c7c7877474ec20ff74d (diff)
downloadcygnal-8ed5c9b6297dce0115a462e6ae1a644a9a278bdb.tar.gz
cygnal-8ed5c9b6297dce0115a462e6ae1a644a9a278bdb.tar.bz2
cygnal-8ed5c9b6297dce0115a462e6ae1a644a9a278bdb.zip
Move open_fhs from fhandler.h to cygheap.h for easier tracking. Accommodate
this change throughout. * dtable.cc (dtable::add_archetype): Use correct count when iterating through *active* archetypes. * dtable.cc (dtable::fixup_after_exec): Close handle if close_on_exec and archetype exists since archetype currently does not set windows close-on-exec flag (FIXME). * fhandler_tty.cc (fhandler_tty_slave::open): Change debugging output slightly. (fhandler_tty_slave::close): Ditto. (fhandler_tty_slave::fixup_after_fork): Just report on inherited use counts since since archetype currently does not set windows close-on-exec flag (FIXME). * pinfo.cc (_pinfo::set_ctty): Change debugging output slightly. * cygheap.cc (cygheap_init): Remove open_fhs accommodation and use count reporting. * perthread.h (vfork_save::fhctty): New element. * perthread.h (vfork_save::open_fhs): New element. * fork.cc (vfork): Muck around with ctty and open_fhs stuff, both of which are now saved in the vfork_save structure.
Diffstat (limited to 'winsup/cygwin/fork.cc')
-rw-r--r--winsup/cygwin/fork.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 7461c0bb4..477d85c0f 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -719,9 +719,11 @@ vfork ()
vf->ctty = myself->ctty;
vf->sid = myself->sid;
vf->pgid = myself->pgid;
+ vf->fhctty = cygheap->ctty;
+ vf->open_fhs = cygheap->open_fhs;
int res = cygheap->fdtab.vfork_child_dup () ? 0 : -1;
debug_printf ("%d = vfork()", res);
- call_signal_handler_now (); // FIXME: racy
+ call_signal_handler_now (); // FIXME: racy
vf->tls = _my_tls;
return res;
}
@@ -737,6 +739,20 @@ vfork ()
myself->ctty = vf->ctty;
myself->sid = vf->sid;
myself->pgid = vf->pgid;
+ termios_printf ("cygheap->ctty %p, vf->fhctty %p", cygheap->ctty, vf->fhctty);
+ if (cygheap->ctty != vf->fhctty)
+ {
+ vf->fhctty->close ();
+ if (vf->pid <= 0)
+ {
+ if (vf->ctty)
+ vf->fhctty->close ();
+ cygheap->ctty = vf->fhctty;
+ }
+ }
+
+ if (vf->pid <= 0)
+ cygheap->open_fhs = vf->open_fhs;
if (vf->pid < 0)
{