mirror of
https://github.com/leahneukirchen/mblaze
synced 2024-11-11 13:10:32 +00:00
filter: use sigpending/sigismember/sigwait instead of sigtimedwait
sigtimedwait is just POSIX.1-2001, which lesser operating systems don't implement completely.
This commit is contained in:
parent
b78cf918db
commit
9e49cf7561
13
filter.c
13
filter.c
@ -15,7 +15,6 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno)
|
|||||||
ssize_t outalloc = 4096;
|
ssize_t outalloc = 4096;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
sigset_t mask, orig_mask;
|
sigset_t mask, orig_mask;
|
||||||
struct timespec immediately = { 0, 0 };
|
|
||||||
|
|
||||||
sigemptyset(&mask);
|
sigemptyset(&mask);
|
||||||
sigaddset(&mask, SIGPIPE);
|
sigaddset(&mask, SIGPIPE);
|
||||||
@ -105,7 +104,11 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno)
|
|||||||
*outputo = output;
|
*outputo = output;
|
||||||
*outleno = outlen;
|
*outleno = outlen;
|
||||||
|
|
||||||
sigtimedwait(&mask, 0, &immediately);
|
sigpending(&mask);
|
||||||
|
if (sigismember(&mask, SIGPIPE)) {
|
||||||
|
int sig;
|
||||||
|
sigwait(&mask, &sig);
|
||||||
|
}
|
||||||
sigprocmask(SIG_SETMASK, &orig_mask, 0);
|
sigprocmask(SIG_SETMASK, &orig_mask, 0);
|
||||||
|
|
||||||
return WEXITSTATUS(status);
|
return WEXITSTATUS(status);
|
||||||
@ -115,7 +118,11 @@ fail:
|
|||||||
*outleno = 0;
|
*outleno = 0;
|
||||||
free(output);
|
free(output);
|
||||||
|
|
||||||
sigtimedwait(&mask, 0, &immediately);
|
sigpending(&mask);
|
||||||
|
if (sigismember(&mask, SIGPIPE)) {
|
||||||
|
int sig;
|
||||||
|
sigwait(&mask, &sig);
|
||||||
|
}
|
||||||
sigprocmask(SIG_SETMASK, &orig_mask, 0);
|
sigprocmask(SIG_SETMASK, &orig_mask, 0);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user