ecore_signal: check the return value of write(2)

Some glibc declare write(2) with the attribute warn unused result.
So we now ensure that the calls to write(2) are successful. Otherwise,
we print an error and update errno accordingly.
This commit is contained in:
Jean Guyomarc'h 2018-02-25 10:40:50 +01:00
parent 7ff60afe5c
commit 87efca57ef
1 changed files with 6 additions and 1 deletions

View File

@ -159,7 +159,12 @@ _ecore_signal_callback(int sig, siginfo_t *si, void *foo EINA_UNUSED)
if (sdata.sig >= 0)
{
int err = errno;
write(sig_pipe[1], &sdata, sizeof(sdata));
const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata));
if (EINA_UNLIKELY(bytes != sizeof(sdata)))
{
err = errno;
ERR("write() failed: %s", strerror(err));
}
errno = err;
}
}