Catch SIGPIPE

Avoids a crash if OpenSSL tries to write to a broken connection with
write().

Obviously OpenSSL really should use send() with MSG_NOSIGNAL, but for
some reason it doesn't. This should probably be considered an OpenSSL
bug, but since in this case we "own" the process, there is no harm in
ignoring the signal.

This is not done with libmpv, because as a library we don't want to mess
with global state. It's also not done if terminal handling is disabled -
this is a bit arbitrary, but I don't care much.
This commit is contained in:
wm4 2014-11-20 21:45:12 +01:00
parent 8a1d5e91ad
commit f93ce21d45
1 changed files with 3 additions and 0 deletions

View File

@ -488,6 +488,9 @@ int terminal_init(void)
setsigaction(SIGTTIN, SIG_IGN, 0, true);
setsigaction(SIGTTOU, SIG_IGN, 0, true);
// don't crash on SIGPIPE caused by semi-broken libraries
setsigaction(SIGPIPE, SIG_IGN, 0, true);
getch2_poll();
return 0;