aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-04-14 20:00:25 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-04-14 20:00:25 +0200
commitad9fe95761c4e1c4ac5430362747fd701887b9b3 (patch)
tree732722831169ac5bb59fcfce992b4804a3c1833d
parent9e49cf7561fa879e7cf0693e763525fbac3e9008 (diff)
downloadmblaze-ad9fe95761c4e1c4ac5430362747fd701887b9b3.tar.gz
filter: simplify clean up logic
-rw-r--r--filter.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/filter.c b/filter.c
index 0baa5e6..111b606 100644
--- a/filter.c
+++ b/filter.c
@@ -15,6 +15,7 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno)
ssize_t outalloc = 4096;
pid_t pid;
sigset_t mask, orig_mask;
+ int r;
sigemptyset(&mask);
sigaddset(&mask, SIGPIPE);
@@ -100,23 +101,18 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno)
int status;
waitpid(pid, &status, 0);
+ r = WEXITSTATUS(status);
*outputo = output;
*outleno = outlen;
- sigpending(&mask);
- if (sigismember(&mask, SIGPIPE)) {
- int sig;
- sigwait(&mask, &sig);
- }
- sigprocmask(SIG_SETMASK, &orig_mask, 0);
-
- return WEXITSTATUS(status);
-
+ if (0) {
fail:
- *outputo = 0;
- *outleno = 0;
- free(output);
+ *outputo = 0;
+ *outleno = 0;
+ free(output);
+ r = -1;
+ }
sigpending(&mask);
if (sigismember(&mask, SIGPIPE)) {
@@ -125,7 +121,7 @@ fail:
}
sigprocmask(SIG_SETMASK, &orig_mask, 0);
- return -1;
+ return r;
}
#ifdef TEST