This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: pexecute.c cleanup


On Wed, Aug 02, 2000 at 01:35:22PM -0700, Mark Mitchell wrote:
> 
> Zack --
> 
>  FWIW, I would prefer we not introduce obscure control flow (i.e.,
> gotos rather than break), simply to quiet a compiler warning,
> especially a buggy one.

That's fair.  How about this patch instead?

zw

	* pexecute.c: Don't use vfork.  Initialize 'pid' before retry loop.

===================================================================
Index: libiberty/pexecute.c
--- libiberty/pexecute.c	2000/07/27 01:48:33	1.19
+++ libiberty/pexecute.c	2000/08/02 20:42:14
@@ -46,19 +46,6 @@ extern int errno;
 #include <sys/wait.h>
 #endif
 
-#ifdef vfork /* Autoconf may define this to fork for us. */
-# define VFORK_STRING "fork"
-#else
-# define VFORK_STRING "vfork"
-#endif
-#ifdef HAVE_VFORK_H
-#include <vfork.h>
-#endif
-#ifdef VMS
-#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
-               lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
-#endif /* VMS */
-
 #include "libiberty.h"
 
 /* stdin file number.  */
@@ -714,9 +701,10 @@ pexecute (program, argv, this_pname, tem
 
   /* Fork a subprocess; wait and retry if it fails.  */
   sleep_interval = 1;
+  pid = -1;
   for (retries = 0; retries < 4; retries++)
     {
-      pid = vfork ();
+      pid = fork ();
       if (pid >= 0)
 	break;
       sleep (sleep_interval);
@@ -726,11 +714,9 @@ pexecute (program, argv, this_pname, tem
   switch (pid)
     {
     case -1:
-      {
-	*errmsg_fmt = VFORK_STRING;
-	*errmsg_arg = NULL;
-	return -1;
-      }
+      *errmsg_fmt = "fork";
+      *errmsg_arg = NULL;
+      return -1;
 
     case 0: /* child */
       /* Move the input and output pipes into place, if necessary.  */
@@ -754,7 +740,6 @@ pexecute (program, argv, this_pname, tem
       /* Exec the program.  */
       (*func) (program, argv);
 
-      /* Note: Calling fprintf and exit here doesn't seem right for vfork.  */
       fprintf (stderr, "%s: ", this_pname);
       fprintf (stderr, install_error_msg, program);
       fprintf (stderr, ": %s\n", xstrerror (errno));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]