The following commit has been merged in the master branch:
commit f29e54ab5ccf99376dfb3a9ac824ea795c260e10
Author: Guillem Jover <[EMAIL PROTECTED]>
Date:   Mon Nov 24 06:25:52 2008 +0200

    libdpkg: Move subprocess related functions from mlib.c to subproc.c

diff --git a/ChangeLog b/ChangeLog
index b7414a7..722b63a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-12-05  Guillem Jover  <[EMAIL PROTECTED]>
 
+       * lib/mlib.c: Remove <sys/wait.h> include.
+       (checksubprocerr, waitsubproc): Move to ...
+       * lib/subproc.c (checksubprocerr, waitsubproc): ... here.
+       Include <sys/types.h> and <sys/wait.h>.
+
+2008-12-05  Guillem Jover  <[EMAIL PROTECTED]>
+
        * lib/mlib.c (checksubprocerr): Split unrelated conditionals for n
        and PROCPIPE.
 
diff --git a/lib/mlib.c b/lib/mlib.c
index b315e70..ac5436f 100644
--- a/lib/mlib.c
+++ b/lib/mlib.c
@@ -32,7 +32,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <sys/wait.h>
 #include <sys/types.h>
 
 #include <dpkg.h>
@@ -118,45 +117,6 @@ void m_pipe(int *fds) {
   ohshite(_("failed to create pipe"));
 }
 
-int checksubprocerr(int status, const char *description, int flags) {
-  int n;
-  if (WIFEXITED(status)) {
-    n = WEXITSTATUS(status);
-    if (!n)
-      return 0;
-    if (flags & PROCNOERR)
-      return -1;
-    if (flags & PROCWARN)
-      warning(_("%s returned error exit status %d"), description, n);
-    else
-      ohshit(_("subprocess %s returned error exit status %d"), description, n);
-  } else if (WIFSIGNALED(status)) {
-    n = WTERMSIG(status);
-    if (!n)
-      return 0;
-    if ((flags & PROCPIPE) && n == SIGPIPE)
-      return 0;
-    if (flags & PROCWARN)
-      warning(_("%s killed by signal (%s)%s"),
-              description, strsignal(n), WCOREDUMP(status) ? _(", core 
dumped") : "");
-    else
-      ohshit(_("subprocess %s killed by signal (%s)%s"),
-            description, strsignal(n), WCOREDUMP(status) ? _(", core dumped") 
: "");
-  } else {
-    ohshit(_("subprocess %s failed with wait status code 
%d"),description,status);
-  }
-  return -1;
-}
-
-int waitsubproc(pid_t pid, const char *description, int flags) {
-  pid_t r;
-  int status;
-
-  while ((r= waitpid(pid,&status,0)) == -1 && errno == EINTR);
-  if (r != pid) { onerr_abort++; ohshite(_("wait for %s failed"),description); 
}
-  return checksubprocerr(status,description,flags);
-}
-
 void setcloexec(int fd, const char* fn) {
   int f;
 
diff --git a/lib/subproc.c b/lib/subproc.c
index 009b9f2..3b855ec 100644
--- a/lib/subproc.c
+++ b/lib/subproc.c
@@ -24,6 +24,8 @@
 
 #include <dpkg-i18n.h>
 
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -68,3 +70,58 @@ cu_subproc_signals(int argc, void **argv)
        }
 }
 
+int
+checksubprocerr(int status, const char *description, int flags)
+{
+       int n;
+
+       if (WIFEXITED(status)) {
+               n = WEXITSTATUS(status);
+               if (!n)
+                       return 0;
+               if (flags & PROCNOERR)
+                       return -1;
+               if (flags & PROCWARN)
+                       warning(_("%s returned error exit status %d"),
+                               description, n);
+               else
+                       ohshit(_("subprocess %s returned error exit status %d"),
+                              description, n);
+       } else if (WIFSIGNALED(status)) {
+               n = WTERMSIG(status);
+               if (!n)
+                       return 0;
+               if ((flags & PROCPIPE) && n == SIGPIPE)
+                       return 0;
+               if (flags & PROCWARN)
+                       warning(_("%s killed by signal (%s)%s"),
+                               description, strsignal(n),
+                               WCOREDUMP(status) ? _(", core dumped") : "");
+               else
+                       ohshit(_("subprocess %s killed by signal (%s)%s"),
+                              description, strsignal(n),
+                              WCOREDUMP(status) ? _(", core dumped") : "");
+       } else {
+               ohshit(_("subprocess %s failed with wait status code %d"),
+                      description, status);
+       }
+
+       return -1;
+}
+
+int
+waitsubproc(pid_t pid, const char *description, int flags)
+{
+       pid_t r;
+       int status;
+
+       while ((r = waitpid(pid, &status, 0)) == -1 && errno == EINTR) ;
+
+       if (r != pid) {
+               onerr_abort++;
+               ohshite(_("wait for %s failed"), description);
+       }
+
+       return checksubprocerr(status, description, flags);
+}
+

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to