* fork-child.c (fork_inferior): Fork instead of vfork if
authorMark Kettenis <kettenis@gnu.org>
Mon, 29 Nov 2004 08:37:14 +0000 (08:37 +0000)
committerMark Kettenis <kettenis@gnu.org>
Mon, 29 Nov 2004 08:37:14 +0000 (08:37 +0000)
PRE_TRACE_FUN is non-null.

gdb/ChangeLog
gdb/fork-child.c

index f5f05744a6b78a2303ca666f9cbee21d7336f045..b7c605df3b9bcd83610d6686bf4ec7a6f5b6accb 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-29  Mark Kettenis  <kettenis@gnu.org>
+
+       * fork-child.c (fork_inferior): Fork instead of vfork if
+       PRE_TRACE_FUN is non-null.
+
 2004-11-24  Fred Fish  <fnf@specifixinc.com>
 
        * rs6000-tdep.c (skip_prologue): Use line table info to skip over
index 90580baaa766b378e48964bac24035455ebcd89d..718a3d2de2129e84b596ed292c4608efb7ba4284 100644 (file)
@@ -274,10 +274,18 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
   if (pre_trace_fun != NULL)
     (*pre_trace_fun) ();
 
-  /* Create the child process.  Note that the apparent call to vfork()
-     below *might* actually be a call to fork() due to the fact that
-     autoconf will ``#define vfork fork'' on certain platforms.  */
-  if (debug_fork)
+  /* Create the child process.  Since the child process is going to
+     exec(3) shortlty afterwards, try to reduce the overhead by
+     calling vfork(2).  However, if PRE_TRACE_FUN is non-null, it's
+     likely that this optimization won't work since there's too much
+     work to do between the vfork(2) and the exec(3).  This is known
+     to be the case on ttrace(2)-based HP-UX, where some handshaking
+     between parent and child needs to happen between fork(2) and
+     exec(2).  However, since the parent is suspended in the vforked
+     state, this doesn't work.  Also note that the vfork(2) call might
+     actually be a call to fork(2) due to the fact that autoconf will
+     ``#define vfork fork'' on certain platforms.  */
+  if (pre_trace_fun || debug_fork)
     pid = fork ();
   else
     pid = vfork ();
This page took 0.032332 seconds and 4 git commands to generate.