aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-04-14 19:52:58 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-04-14 19:52:58 +0200
commit9e49cf7561fa879e7cf0693e763525fbac3e9008 (patch)
tree2ceee49489bc70a39f1c9932cd341a9fe9a67376
parentb78cf918dbc0ff871bc0e45af9e54f28c5430b64 (diff)
downloadmblaze-9e49cf7561fa879e7cf0693e763525fbac3e9008.tar.gz
filter: use sigpending/sigismember/sigwait instead of sigtimedwait
sigtimedwait is just POSIX.1-2001, which lesser operating systems don't implement completely.
-rw-r--r--filter.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/filter.c b/filter.c
index a9bd45b..0baa5e6 100644
--- a/filter.c
+++ b/filter.c
@@ -15,7 +15,6 @@ 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);
@@ -105,7 +104,11 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno)
*outputo = output;
*outleno = outlen;
- sigtimedwait(&mask, 0, &immediately);
+ sigpending(&mask);
+ if (sigismember(&mask, SIGPIPE)) {
+ int sig;
+ sigwait(&mask, &sig);
+ }
sigprocmask(SIG_SETMASK, &orig_mask, 0);
return WEXITSTATUS(status);
@@ -115,7 +118,11 @@ fail:
*outleno = 0;
free(output);
- sigtimedwait(&mask, 0, &immediately);
+ sigpending(&mask);
+ if (sigismember(&mask, SIGPIPE)) {
+ int sig;
+ sigwait(&mask, &sig);
+ }
sigprocmask(SIG_SETMASK, &orig_mask, 0);
return -1;