/* -*-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
*
/*----- 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.
else {
int pfd[2];
struct sigaction sa;
+ sigset_t newmask, oldmask;
/* --- Set up a signal handler --- */
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));
write(STDERR_FILENO, d.buf, d.len);
_exit(127);
}
+
+ sigprocmask(SIG_SETMASK, &oldmask, 0);
fd = pfd[0];
close(pfd[1]);
}