From 47026c0785a0cd86c05f8255cc34a85c1cf9eced Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 3 Aug 2000 03:02:41 +0000 Subject: * fork.cc (vfork): Store complete stack frame in vfork_save structure for later recovery. * spawn.cc (spawn_guts): Reorganize slightly to consolidate handling when there is a CreateProcess error. (_spawnve): Only longjmp back to vfork handling when a process has been successfuly started. * winsup.h (vfork_save): Extend to include frame info. Remove obsolete cpplus conditionals. --- winsup/cygwin/ChangeLog | 11 +++++++++++ winsup/cygwin/fork.cc | 14 ++++++++++---- winsup/cygwin/spawn.cc | 19 ++++++++++--------- winsup/cygwin/winsup.h | 11 ++--------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 81d01516c..e10e86d93 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +Wed Aug 2 22:58:07 2000 Christopher Faylor + + * fork.cc (vfork): Store complete stack frame in vfork_save structure + for later recovery. + * spawn.cc (spawn_guts): Reorganize slightly to consolidate handling + when there is a CreateProcess error. + (_spawnve): Only longjmp back to vfork handling when a process has been + successfuly started. + * winsup.h (vfork_save): Extend to include frame info. Remove obsolete + cpplus conditionals. + Wed Aug 2 15:14:51 2000 Christopher Faylor * strace.cc (strace::prntf): Make second argument the function name, diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 7eb43b6be..6052bac7f 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -639,6 +639,7 @@ vfork () return fork (); #else vfork_save *vf = get_vfork_val (); + char **esp, **pp; if (vf == NULL) vf = vfork_storage.create (); @@ -646,9 +647,11 @@ vfork () if (!setjmp (vf->j)) { vf->pid = -1; + __asm__ volatile ("movl %%esp,%0": "=r" (vf->vfork_esp):); __asm__ volatile ("movl %%ebp,%0": "=r" (vf->vfork_ebp):); - __asm__ volatile ("movl (%%ebp),%0": "=r" (vf->caller_ebp):); - __asm__ volatile ("movl 4(%%ebp),%0": "=r" (vf->retaddr):); + for (pp = (char **)vf->frame, esp = vf->vfork_esp; + esp <= vf->vfork_ebp + 1; pp++, esp++) + *pp = *esp; return dtable.vfork_child_dup () ? 0 : -1; } @@ -662,8 +665,11 @@ vfork () exit (exitval); } - vf->vfork_ebp[0] = vf->caller_ebp; - vf->vfork_ebp[1] = vf->retaddr; + __asm__ volatile ("movl %%esp,%0": "=r" (esp):); + for (pp = (char **)vf->frame, esp = vf->vfork_esp; + esp <= vf->vfork_ebp + 1; pp++, esp++) + *esp = *pp; + return vf->pid; #endif } diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 7d3063c31..be35a0b7d 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -607,7 +607,15 @@ skip_arg_parsing: final debugging message [this is a general rule for debugging messages]. */ if (!rc) - __seterrno (); + + if (!rc) + { + if (spr) + ForceCloseHandle (spr); + __seterrno (); + syscall_printf ("CreateProcess failed, %E"); + return -1; + } if (mode == _P_OVERLAY) cygpid = myself->pid; @@ -619,13 +627,6 @@ skip_arg_parsing: rc ? cygpid : (unsigned int) -1, prog_arg, one_line.buf); - if (!rc) - { - if (spr) - ForceCloseHandle (spr); - return -1; - } - MALLOC_CHECK; /* Name the handle similarly to proc_subproc. */ ProtectHandle1 (pi.hProcess, childhProc); @@ -884,7 +885,7 @@ _spawnve (HANDLE hToken, int mode, const char *path, const char *const *argv, case _P_DETACH: subproc_init (); ret = spawn_guts (hToken, path, argv, envp, mode); - if (vf) + if (vf && ret > 0) { vf->pid = ret; longjmp (vf->j, 1); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 9a92df214..ff684628e 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -224,9 +224,9 @@ struct vfork_save { int pid; jmp_buf j; + DWORD frame[100]; char **vfork_ebp; - char *caller_ebp; - char *retaddr; + char **vfork_esp; int is_active () { return pid < 0; } }; @@ -460,9 +460,6 @@ extern void (*__DTOR_LIST__) (void); /* Initial and increment values for cygwin's fd table */ #define NOFILE_INCR 32 -#ifdef __cplusplus -extern "C" { -#endif #include #define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH) @@ -472,10 +469,6 @@ extern "C" { #define O_NOSYMLINK 0x080000 #define O_DIROPEN 0x100000 -#ifdef __cplusplus -} -#endif - /*************************** Environment ******************************/ /* The structure below is used to control conversion to/from posix-style -- cgit v1.2.3