From 7ff60afe5c164f0a10b3c9fbdf405c364d91b0d5 Mon Sep 17 00:00:00 2001 From: Jean Guyomarc'h Date: Sun, 25 Feb 2018 10:38:57 +0100 Subject: [PATCH] efl_exe: check the calls to pipe(2) Some glibc versions declare pipe(2) with a warn unused result attribute, leading to compile-time warnings when pipe(2)'s return value is not checked. If pipe(2) fails, we now print an error and make the calling function fail. --- src/lib/ecore/efl_exe.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/lib/ecore/efl_exe.c b/src/lib/ecore/efl_exe.c index 40b933cf8d..ed9c53c583 100644 --- a/src/lib/ecore/efl_exe.c +++ b/src/lib/ecore/efl_exe.c @@ -344,6 +344,7 @@ _efl_exe_efl_task_run(Eo *obj EINA_UNUSED, Efl_Exe_Data *pd) int pipe_stdin[2]; int pipe_stdout[2]; int pipe_exited[2]; + int ret; if (pd->pid != -1) return EINA_FALSE; if (!td) return EINA_FALSE; @@ -352,7 +353,14 @@ _efl_exe_efl_task_run(Eo *obj EINA_UNUSED, Efl_Exe_Data *pd) cmd = efl_task_command_get(obj); if (!cmd) return EINA_FALSE; - pipe(pipe_exited); + ret = pipe(pipe_exited); + if (EINA_UNLIKELY(ret != 0)) + { + const int error = errno; + ERR("pipe() failed: %s", strerror(error)); + return EINA_FALSE; + } + pd->fd.exited_read = pipe_exited[0]; eina_file_close_on_exec(pd->fd.exited_write, EINA_TRUE); pd->fd.exited_write = pipe_exited[1]; @@ -360,7 +368,13 @@ _efl_exe_efl_task_run(Eo *obj EINA_UNUSED, Efl_Exe_Data *pd) if (pd->flags & EFL_EXE_FLAGS_USE_STDIN) { - pipe(pipe_stdin); + ret = pipe(pipe_stdin); + if (EINA_UNLIKELY(ret != 0)) + { + const int error = errno; + ERR("pipe() failed: %s", strerror(error)); + return EINA_FALSE; + } pd->fd.in = pipe_stdin[1]; fcntl(pd->fd.in, F_SETFL, O_NONBLOCK); eina_file_close_on_exec(pd->fd.in, EINA_TRUE); @@ -372,7 +386,13 @@ _efl_exe_efl_task_run(Eo *obj EINA_UNUSED, Efl_Exe_Data *pd) } if (pd->flags & EFL_EXE_FLAGS_USE_STDOUT) { - pipe(pipe_stdout); + ret = pipe(pipe_stdout); + if (EINA_UNLIKELY(ret != 0)) + { + const int error = errno; + ERR("pipe() failed: %s", strerror(error)); + return EINA_FALSE; + } pd->fd.out = pipe_stdout[0]; fcntl(pd->fd.out, F_SETFL, O_NONBLOCK); eina_file_close_on_exec(pd->fd.out, EINA_TRUE);