* perthread.h (vfork_save): Add ctty, sid, pgid, exitval fields.

(vfork_save::restore_pid): New method.
(vfork_save::restore_exit): New method.
* fork.cc (vfork): Save ctty, sid, pgid and restore them when returning to
"parent".  Use exitval field if exiting but never created a new process.
* syscalls.cc (setsid): Detect when in "vfork" and force an actual fork so that
pid will be allocated (UGLY!).
(getsid): New function.
* dcrt0.cc (do_exit): Use vfork_save::restore_exit method for returning from a
vfork.
* spawn.cc (spawnve): Use vfork_save::{restore_pid,restore_exit} methods for
returning from vfork.
* cygwin.din: Export getsid.
* include/cygwin/version.h: Bump api minor number.
* malloc.cc: #ifdef sYSTRIm for when MORECORE_CANNOT_TRIM is true.
This commit is contained in:
Christopher Faylor
2002-08-18 05:49:26 +00:00
parent d17ba05c1c
commit 8dca9e2302
9 changed files with 99 additions and 19 deletions

View File

@ -687,8 +687,7 @@ get_vfork_val ()
}
#endif
extern "C"
int
extern "C" int
vfork ()
{
#ifndef NEWVFORK
@ -711,9 +710,11 @@ vfork ()
for (pp = (char **)vf->frame, esp = vf->vfork_esp;
esp <= vf->vfork_ebp + 2; pp++, esp++)
*pp = *esp;
vf->ctty = myself->ctty;
vf->sid = myself->sid;
vf->pgid = myself->pgid;
int res = cygheap->fdtab.vfork_child_dup () ? 0 : -1;
debug_printf ("%d = vfork()", res);
debug_printf ("exiting vfork, res %d", res);
return res;
}
@ -726,9 +727,13 @@ vfork ()
thisframe.init (mainthread);
cygheap->fdtab.vfork_parent_restore ();
myself->ctty = vf->ctty;
myself->sid = vf->sid;
myself->pgid = vf->pgid;
if (vf->pid < 0)
{
int exitval = -vf->pid;
int exitval = vf->exitval;
vf->pid = 0;
if ((vf->pid = fork ()) == 0)
exit (exitval);