SIGPIPE now runs with a no-op sighandler, instead of SIG_IGN. This is
so that if scsh exec's a sleazy C program that needs the default kill-me-I'm-a-loser action of SIGPIPE, the handler will be reset to SIG_DFL on exec, rather than continue to be ignored.
This commit is contained in:
parent
459658efa6
commit
18e8530076
22
unix.c
22
unix.c
|
@ -103,6 +103,18 @@ extern long Spending_interruptsS;
|
|||
|
||||
/* Signal handlers */
|
||||
|
||||
/* Note that we turn off SIGPIPE interrupts in a funny way -- we don't
|
||||
** set the handler to SIGIGN, we set it to a no-op function. This is so
|
||||
** that when we exec() some other program, the handler will be reset to
|
||||
** its default, rather than to SIGIGN.
|
||||
**
|
||||
** We don't use SIGPIPE, because all write() calls in scsh correctly check
|
||||
** for error returns, and raise an error exception. Sleazy Unix C programs,
|
||||
** however, need to get shot down when writing to a closed pipe or socket.
|
||||
** -Olin 4/97
|
||||
*/
|
||||
|
||||
|
||||
static RETSIGTYPE
|
||||
when_keyboard_interrupt(sig, code, scp)
|
||||
int sig, code;
|
||||
|
@ -124,6 +136,14 @@ when_alarm_interrupt(sig, code, scp)
|
|||
return;
|
||||
}
|
||||
|
||||
static RETSIGTYPE
|
||||
when_pipe_interrupt(sig, code, scp)
|
||||
int sig, code;
|
||||
struct sigcontext *scp;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* OS-dependent initialization */
|
||||
|
||||
|
@ -145,7 +165,7 @@ sysdep_init()
|
|||
|
||||
/* SIGPIPE's are bogus. -Olin */
|
||||
{struct sigaction sa;
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sa.sa_handler = when_pipe_interrupt;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sigaction(SIGPIPE, &sa, NULL);
|
||||
|
|
Loading…
Reference in New Issue