ecore/signal: also use nonblock for writing side of signal pipe

if any efl-based process receives a bunch of signals in a short period of
time, it will deadlock in the signal handler. this is unavoidable given the
current signal handling architecture

by setting nonblock, we can at least avoid deadlocking even if it means we'll
be losing signal events

@fix

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10025
This commit is contained in:
Mike Blumenkrantz 2019-09-19 14:03:59 -04:00 committed by Cedric Bail
parent 539dc642e9
commit aae2e49744
1 changed files with 12 additions and 6 deletions

View File

@ -168,13 +168,17 @@ _ecore_signal_callback(int sig, siginfo_t *si, void *foo EINA_UNUSED)
{
int err = errno;
if (pipe_dead) return;
const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata));
if (EINA_UNLIKELY(bytes != sizeof(sdata)))
do
{
err = errno;
ERR("write() failed: %s", strerror(err));
}
errno = err;
const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata));
if (EINA_UNLIKELY(bytes != sizeof(sdata)))
{
err = errno;
ERR("write() failed: %d: %s", err, strerror(err));
}
errno = err;
/* loop if we got preempted */
} while (err == EINTR);
}
switch (sig)
{
@ -249,6 +253,8 @@ _ecore_signal_pipe_init(void)
eina_file_close_on_exec(sig_pipe[1], EINA_TRUE);
if (fcntl(sig_pipe[0], F_SETFL, O_NONBLOCK) < 0)
ERR("can't set pipe to NONBLOCK");
if (fcntl(sig_pipe[1], F_SETFL, O_NONBLOCK) < 0)
ERR("can't set pipe to NONBLOCK");
}
_signalhandler_setup();