OSDN Git Service

* fork.cc (vfork): Store complete stack frame in vfork_save structure for later
authorcgf <cgf>
Thu, 3 Aug 2000 03:02:41 +0000 (03:02 +0000)
committercgf <cgf>
Thu, 3 Aug 2000 03:02:41 +0000 (03:02 +0000)
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
winsup/cygwin/fork.cc
winsup/cygwin/spawn.cc
winsup/cygwin/winsup.h

index 81d0151..e10e86d 100644 (file)
@@ -1,3 +1,14 @@
+Wed Aug  2 22:58:07 2000  Christopher Faylor <cgf@cygnus.com>
+
+       * 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 <cgf@cygnus.com>
 
        * strace.cc (strace::prntf): Make second argument the function name,
index 7eb43b6..6052bac 100644 (file)
@@ -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
 }
index 7d3063c..be35a0b 100644 (file)
@@ -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);
index 9a92df2..ff68462 100644 (file)
@@ -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 <sys/reent.h>
 
 #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