mblaze

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

commit b78cf918dbc0ff871bc0e45af9e54f28c5430b64
parent 6fae889a13757197c0180166c5518aea44a12a4c
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Fri, 14 Apr 2017 02:22:12 +0200

filter: use sigtimedwait with zero wait time

Else it will block until SIGPIPE comes.

Diffstat:
filter.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

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