aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-04-14 02:22:12 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-04-14 02:22:12 +0200
commitb78cf918dbc0ff871bc0e45af9e54f28c5430b64 (patch)
treea25c3fe8ad34fbde88cdbb3914fcb9be4dc7536c
parent6fae889a13757197c0180166c5518aea44a12a4c (diff)
downloadmblaze-b78cf918dbc0ff871bc0e45af9e54f28c5430b64.tar.gz
filter: use sigtimedwait with zero wait time
Else it will block until SIGPIPE comes.
-rw-r--r--filter.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/filter.c b/filter.c
index 1a03598..a9bd45b 100644
--- a/filter.c
+++ b/filter.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
+#include <time.h>
#include <unistd.h>
int
@@ -14,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;
+ struct timespec immediately = { 0, 0 };
sigemptyset(&mask);
sigaddset(&mask, SIGPIPE);
@@ -103,7 +105,7 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno)
*outputo = output;
*outleno = outlen;
- sigwaitinfo(&mask, 0);
+ sigtimedwait(&mask, 0, &immediately);
sigprocmask(SIG_SETMASK, &orig_mask, 0);
return WEXITSTATUS(status);
@@ -113,7 +115,7 @@ fail:
*outleno = 0;
free(output);
- sigwaitinfo(&mask, 0);
+ sigtimedwait(&mask, 0, &immediately);
sigprocmask(SIG_SETMASK, &orig_mask, 0);
return -1;