On Tue, 15 Aug 2006, David Rientjes wrote:
Please cite where this function is specified to return zero on success and not
the return value of waitpid which, after all, is the only assignment to the
return value. waitpid only returns when the status of the child is available or
an error has occurred as a result of an interrupt. The correct interface, in my
opinion, for this function is to return what waitpid returns and allow it to
indicate the pid of the child or interrupt to the caller. The signature now
suggests that. If Linus did indeed write this, he did so to spin until the
status of the child was known.
Forget this, the function is correct as is because EINTR is only returned on
signal interrupt and ret is set to -1 (by the waitpid spec) implicitly.
Please replace the original patch with the following.
Replaces types with appropriate typedefs.
David
Signed-off-by: David Rientjes <rientjes@google.com>
---
builtin-apply.c | 2 +-
fetch-clone.c | 3 +--
merge-index.c | 3 ++-
run-command.c | 8 ++++----
unpack-trees.c | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 9cf477c..56c5394 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2097,7 +2097,7 @@ static void create_one_file(char *path,
}
if (errno == EEXIST) {
- unsigned int nr = getpid();
+ pid_t nr = getpid();
for (;;) {
const char *newpath;diff --git a/fetch-clone.c b/fetch-clone.c
index 5e84c46..c5cf477 100644
--- a/fetch-clone.c
+++ b/fetch-clone.c
@@ -44,9 +44,8 @@ static int finish_pack(const char *pack_
for (;;) {
int status, code;
- int retval = waitpid(pid, &status, 0);
- if (retval < 0) {
+ if (waitpid(pid, &status, 0) < 0) {
if (errno == EINTR)
continue;
error("waitpid failed (%s)", strerror(errno));diff --git a/merge-index.c b/merge-index.c
index 0498a6f..a9c8cc1 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -11,7 +11,8 @@ static int err;
static void run_program(void)
{
- int pid = fork(), status;
+ pid_t pid = fork();
+ int status;
if (pid < 0)
die("unable to fork");diff --git a/run-command.c b/run-command.c
index ca67ee9..3bacc1b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -25,15 +25,15 @@ int run_command_v_opt(int argc, const ch
}
for (;;) {
int status, code;
- int retval = waitpid(pid, &status, 0);
+ pid_t waiting = waitpid(pid, &status, 0);
- if (retval < 0) {
+ if (waiting < 0) {
if (errno == EINTR)
continue;
- error("waitpid failed (%s)", strerror(retval));
+ error("waitpid failed (%s)", strerror(waiting));
return -ERR_RUN_COMMAND_WAITPID;
}
- if (retval != pid)
+ if (waiting != pid)
return -ERR_RUN_COMMAND_WAITPID_WRONG_PID;
if (WIFSIGNALED(status))
return -ERR_RUN_COMMAND_WAITPID_SIGNAL;diff --git a/unpack-trees.c b/unpack-trees.c
index a20639b..e496d8c 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -278,7 +278,7 @@ static void unlink_entry(char *name)
}
}
-static volatile int progress_update = 0;
+static volatile sig_atomic_t progress_update = 0;
static void progress_interval(int signum)
{--
1.4.2.g460c-dirty