bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

install.c: fix obscure compile-time failure on Linux


From: Jim Meyering
Subject: install.c: fix obscure compile-time failure on Linux
Date: Sat, 17 Mar 2007 10:44:06 +0100

When configured like this (note the compile options),
install.c no longer compiles on Linux:

  gcc  -I. -I../lib  -I../lib   -Werror -ansi -pedantic -Wno-long-long -MT 
install.o -MD -MP -MF .deps/install.Tpo -c -o install.o install.c
  install.c: In function `strip':
  install.c:570: error: incompatible type for argument 1 of `wait'
  make[2]: *** [install.o] Error 1

Rather than investigate,
I'm taking this opportunity to upgrade to the use of waitpid.

        Avoid an obscure build failure, prefer waitpid over wait.
        * src/install.c (strip): Use waitpid, not wait.  It's equivalent,
        but feels less obsolescent.

diff --git a/src/install.c b/src/install.c
index 8fc6a8a..0457751 100644
--- a/src/install.c
+++ b/src/install.c
@@ -566,11 +566,10 @@ strip (char const *name)
       error (EXIT_FAILURE, errno, _("cannot run strip"));
       break;
     default:                   /* Parent. */
-      /* Parent process. */
-      while (pid != wait (&status))    /* Wait for kid to finish. */
-       /* Do nothing. */ ;
-      if (status)
-       error (EXIT_FAILURE, 0, _("strip failed"));
+      if (waitpid (pid, &status, 0) < 0)
+       error (EXIT_FAILURE, errno, _("waiting for strip"));
+      else if (! WIFEXITED (status) || WEXITSTATUS (status))
+       error (EXIT_FAILURE, 0, _("strip process terminated abnormally"));
       break;
     }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]