[2585] in BarnOwl Developers
[PATCH] Handle EINTR during waitpid calls
daemon@ATHENA.MIT.EDU (Anders Kaseorg)
Sat Aug 7 03:12:39 2010
Date: Sat, 7 Aug 2010 03:12:35 -0400 (EDT)
From: Anders Kaseorg <andersk@MIT.EDU>
To: barnowl-dev@mit.edu
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
filterproc.c | 4 +++-
popexec.c | 5 ++++-
zcrypt.c | 4 +++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/filterproc.c b/filterproc.c
index 6cc0c51..d9b3fda 100644
--- a/filterproc.c
+++ b/filterproc.c
@@ -6,6 +6,7 @@
#include <poll.h>
#include <fcntl.h>
#include <string.h>
+#include <errno.h>
#include <glib.h>
@@ -91,7 +92,8 @@ int call_filter(const char *prog, const char *const *argv, const char *in, char
close(wfd[0]);
err = send_receive(rfd[0], wfd[1], in, out);
if(err == 0) {
- waitpid(pid, status, 0);
+ while (waitpid(pid, status, 0) == -1 && errno == EINTR)
+ ;
}
} else {
/* child */
diff --git a/popexec.c b/popexec.c
index 53b25aa..d65855d 100644
--- a/popexec.c
+++ b/popexec.c
@@ -6,6 +6,7 @@
#include <sys/filio.h>
#endif
#include <sys/wait.h>
+#include <errno.h>
/* starts up popexec in a new viewwin */
owl_popexec *owl_popexec_new(const char *command)
@@ -158,7 +159,9 @@ void owl_popexec_viewwin_onclose(owl_viewwin *vwin, void *data)
/* TODO: we should handle the case where SIGTERM isn't good enough */
rv = kill(pe->pid, SIGTERM);
owl_function_debugmsg("kill of pid %d returned %d", pe->pid, rv);
- rv = waitpid(pe->pid, &status, 0);
+ do
+ rv = waitpid(pe->pid, &status, 0);
+ while (rv == -1 && errno == EINTR);
owl_function_debugmsg("waidpid returned %d, status %d", rv, status);
pe->pid = 0;
}
diff --git a/zcrypt.c b/zcrypt.c
index f488a69..16a668f 100644
--- a/zcrypt.c
+++ b/zcrypt.c
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <ctype.h>
+#include <errno.h>
#include "config.h"
@@ -565,7 +566,8 @@ FILE *GetZephyrPipe(const char *class, const char *instance, const ZWRITEOPTIONS
void CloseZephyrPipe(FILE *pipe)
{
fclose(pipe);
- waitpid(zephyrpipe_pid, NULL, 0);
+ while (waitpid(zephyrpipe_pid, NULL, 0) == -1 && errno == EINTR)
+ ;
zephyrpipe_pid = 0;
}
--
1.7.2