mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 9e49cf7561fa879e7cf0693e763525fbac3e9008
parent b78cf918dbc0ff871bc0e45af9e54f28c5430b64
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Fri, 14 Apr 2017 19:52:58 +0200

filter: use sigpending/sigismember/sigwait instead of sigtimedwait

sigtimedwait is just POSIX.1-2001, which lesser operating systems don't
implement completely.

Diffstat:
filter.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git 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;