summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2018-02-25 10:38:57 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2018-02-25 10:38:57 +0100
commit7ff60afe5c164f0a10b3c9fbdf405c364d91b0d5 (patch)
tree2315f77b9888cf7418c78388358174a84ffd1d75
parent85ebb13abcbc0ce26f7beb8e01e76abde82cb6a2 (diff)
downloadefl-7ff60afe5c164f0a10b3c9fbdf405c364d91b0d5.tar.gz
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.
-rw-r--r--src/lib/ecore/efl_exe.c26
1 files 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);