What does signal(SIGPIPE, SIG_IGN); do?

23.3k Views Asked by At

I know the individual uses of SIGPIPE and SIGIGN.

What does

signal(SIGPIPE, SIG_IGN);

exactly do?

1

There are 1 best solutions below

6
On BEST ANSWER
signal(SIGPIPE, SIG_IGN);

simply ignores the signal SIGPIPE. Passing SIG_IGN as handler ignores a given signal (except the signals SIGKILL and SIGSTOP which can't caught or ignored).

As an aside, it's generally recommended to use sigaction(2) over signal(2) as sigaction offers better control and also don't need to "reset" the handler on some systems (which follow the System V signal behaviour).