Always block SIGPIPE globally

OpenSSL and GnuTLS are still causing this problem (although FFmpeg could
be blamed as well - but not really). In particular, it was happening to
libmpv users and in cases the pseudo-gui profile is used. This was
because all signal handling is in the terminal code, so if terminal is
disabled, it won't be set. This was obviously a questionable shortcut.

Avoid further problems by always blocking the signal. This is done even
for libmpv, despite our policy of not messing with global state.

Explicitly document this in the libmpv docs. It turns out that a version
bump to 1.17 was forgotten for the addition of MPV_FORMAT_BYTE_ARRAY, so
document that change as part of 1.16.
This commit is contained in:
wm4 2015-05-11 17:38:35 +02:00
parent a5aa58c63c
commit 4858c47e1c
4 changed files with 14 additions and 7 deletions

View File

@ -25,10 +25,11 @@ API changes
::
1.17 - mpv_initialize() now blocks SIGPIPE (details see client.h)
--- mpv 0.9.0 is released ---
1.17 - add MPV_FORMAT_BYTE_ARRAY
1.16 - add mpv_opengl_cb_report_flip()
- introduce mpv_opengl_cb_draw() and deprecate mpv_opengl_cb_render()
- add MPV_FORMAT_BYTE_ARRAY
1.15 - mpv_initialize() will now load config files. This requires setting
the "config" and "config-dir" options. In particular, it will load
mpv.conf.

View File

@ -118,8 +118,10 @@ extern "C" {
* (used through libass), ALSA, FFmpeg, and possibly more.
* - The FPU precision must be set at least to double precision.
* - On Windows, mpv will call timeBeginPeriod(1).
* - SIGPIPE should be blocked. Some parts rely on this signal not crashing the
* process (such as ffmpeg OpenSSL support, or the mpv IPC code).
* - On UNIX, every mpv_initialize() call will block SIGPIPE. This is done
* because FFmpeg makes unsafe use of OpenSSL and GnuTLS, which can raise
* this signal under certain circumstances. Once these libraries (or FFmpeg)
* are fixed, libmpv will not block the signal anymore.
* - On memory exhaustion, mpv will kill the process.
*
* Encoding of filenames
@ -196,7 +198,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 16)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 17)
/**
* Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with.

View File

@ -488,9 +488,6 @@ int terminal_init(void)
setsigaction(SIGTTIN, SIG_IGN, 0, true);
setsigaction(SIGTTOU, SIG_IGN, 0, true);
// get sane behavior, instead of hysteric UNIX-nonsense
setsigaction(SIGPIPE, SIG_IGN, 0, true);
getch2_poll();
return 0;

View File

@ -22,6 +22,7 @@
#include <assert.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include "config.h"
#include "talloc.h"
@ -489,6 +490,12 @@ int mp_initialize(struct MPContext *mpctx, char **options)
if (opts->w32_priority > 0)
SetPriorityClass(GetCurrentProcess(), opts->w32_priority);
#endif
#ifndef _WIN32
// Deal with OpenSSL and GnuTLS not using MSG_NOSIGNAL.
struct sigaction sa = { .sa_handler = SIG_IGN, .sa_flags = SA_RESTART };
sigfillset(&sa.sa_mask);
sigaction(SIGPIPE, &sa, NULL);
#endif
prepare_playlist(mpctx, mpctx->playlist);