The following commit has been merged in the master branch:
commit a720b6aec5ab71211067cfd0250b57efa0aa18f9
Author: Guillem Jover <[email protected]>
Date: Sat Nov 7 00:30:16 2009 +0100
Use subproc_wait instead of directly calling waitpid
diff --git a/dselect/method.cc b/dselect/method.cc
index 4f1c8b1..5f39663 100644
--- a/dselect/method.cc
+++ b/dselect/method.cc
@@ -138,7 +138,7 @@ static enum urqresult lockmethod(void) {
urqresult falliblesubprocess(const char *exepath, const char *name,
const char *const *args) {
- pid_t c1, cr;
+ pid_t c1;
int status, i, c;
cursesoff();
@@ -151,10 +151,7 @@ urqresult falliblesubprocess(const char *exepath, const
char *name,
ohshite(_("unable to run %.250s process `%.250s'"),name,exepath);
}
- while ((cr= waitpid(c1,&status,0)) == -1)
- if (errno != EINTR) ohshite(_("unable to wait for %.250s"),name);
- if (cr != c1)
- ohshit(_("got wrong child's status - asked for %ld, got
%ld"),(long)c1,(long)cr);
+ status = subproc_wait(c1, name);
pop_cleanup(ehflag_normaltidy);
diff --git a/src/configure.c b/src/configure.c
index 3ae745b..f5254bc 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -46,6 +46,7 @@
#include <dpkg/dpkg-db.h>
#include <dpkg/buffer.h>
#include <dpkg/file.h>
+#include <dpkg/subproc.h>
#include "filesdb.h"
#include "main.h"
@@ -489,8 +490,6 @@ static void
showdiff(const char *old, const char *new)
{
int pid;
- int r;
- int status;
pid = m_fork();
if (!pid) {
@@ -514,13 +513,7 @@ showdiff(const char *old, const char *new)
}
/* Parent process. */
- while (((r = waitpid(pid, &status, 0)) == -1) && (errno == EINTR))
- ;
-
- if (r != pid) {
- onerr_abort++;
- ohshite(_("wait for shell failed"));
- }
+ subproc_wait(pid, "shell");
}
/**
@@ -540,9 +533,6 @@ suspend(void)
/* Do not job control to suspend but fork and start a new
* shell instead. */
- int status; /* waitpid status */
- int r; /* waitpid result */
-
fputs(_("Type `exit' when you're done.\n"), stderr);
pid = m_fork();
@@ -557,13 +547,7 @@ suspend(void)
}
/* Parent process. */
- while (((r = waitpid(pid, &status, 0)) == -1) && (errno ==
EINTR))
- ;
-
- if (r != pid) {
- onerr_abort++;
- ohshite(_("wait for shell failed"));
- }
+ subproc_wait(pid, "shell");
} else {
fputs(_("Don't forget to foreground (`fg') this "
"process when you're done !\n"), stderr);
diff --git a/src/processarc.c b/src/processarc.c
index 57ad472..e3a41b9 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -127,8 +127,7 @@ void process_archive(const char *filename) {
execlp(SPLITTER, SPLITTER, "-Qao", reasmbuf, filename, NULL);
ohshite(_("failed to exec dpkg-split to see if it's part of a
multiparter"));
}
- while ((r= waitpid(c1,&status,0)) == -1 && errno == EINTR);
- if (r != c1) { onerr_abort++; ohshite(_("wait for dpkg-split failed")); }
+ status = subproc_wait(c1, SPLITTER);
switch (WIFEXITED(status) ? WEXITSTATUS(status) : -1) {
case 0:
/* It was a part - is it complete ? */
@@ -157,7 +156,8 @@ void process_archive(const char *filename) {
ohshite(_("failed to execl debsig-verify"));
} else {
int status;
- waitpid(c1, &status, 0);
+
+ status = subproc_wait(c1, "debsig-verify");
if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) {
if (! fc_badverify) {
ohshit(_("Verification on package %s failed!"), filename);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]