From 95e29d952ecd82c555827174fc38bc2ca8e8dee0 Mon Sep 17 00:00:00 2001 From: mdw Date: Wed, 5 May 1999 18:55:18 +0000 Subject: [PATCH] Block SIGCHLD around the `fork' call to prevent a race. --- xcatch.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xcatch.c b/xcatch.c index 43d3b02..a341cb1 100644 --- a/xcatch.c +++ b/xcatch.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: xcatch.c,v 1.4 1999/03/24 22:23:57 mdw Exp $ + * $Id: xcatch.c,v 1.5 1999/05/05 18:55:18 mdw Exp $ * * Catch input and trap it in an X window * @@ -29,6 +29,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: xcatch.c,v $ + * Revision 1.5 1999/05/05 18:55:18 mdw + * Block SIGCHLD around the `fork' call to prevent a race. + * * Revision 1.4 1999/03/24 22:23:57 mdw * Improve display for large files. Keep newly added material in view if * scrolled to bottom of window. @@ -327,6 +330,7 @@ int main(int argc, char *argv[]) else { int pfd[2]; struct sigaction sa; + sigset_t newmask, oldmask; /* --- Set up a signal handler --- */ @@ -339,6 +343,11 @@ int main(int argc, char *argv[]) if (pipe(pfd)) die(1, "couldn't open pipe: %s", strerror(errno)); + + sigemptyset(&newmask); + sigaddset(&newmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &newmask, &oldmask); + kid = fork(); if (kid < 0) die(1, "couldn't fork: %s", strerror(errno)); @@ -360,6 +369,8 @@ int main(int argc, char *argv[]) write(STDERR_FILENO, d.buf, d.len); _exit(127); } + + sigprocmask(SIG_SETMASK, &oldmask, 0); fd = pfd[0]; close(pfd[1]); } -- 2.11.0