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)
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)
344 int pipe_stdin[2]; 344 int pipe_stdin[2];
345 int pipe_stdout[2]; 345 int pipe_stdout[2];
346 int pipe_exited[2]; 346 int pipe_exited[2];
347 int ret;
347 348
348 if (pd->pid != -1) return EINA_FALSE; 349 if (pd->pid != -1) return EINA_FALSE;
349 if (!td) return EINA_FALSE; 350 if (!td) return EINA_FALSE;
@@ -352,7 +353,14 @@ _efl_exe_efl_task_run(Eo *obj EINA_UNUSED, Efl_Exe_Data *pd)
352 cmd = efl_task_command_get(obj); 353 cmd = efl_task_command_get(obj);
353 if (!cmd) return EINA_FALSE; 354 if (!cmd) return EINA_FALSE;
354 355
355 pipe(pipe_exited); 356 ret = pipe(pipe_exited);
357 if (EINA_UNLIKELY(ret != 0))
358 {
359 const int error = errno;
360 ERR("pipe() failed: %s", strerror(error));
361 return EINA_FALSE;
362 }
363
356 pd->fd.exited_read = pipe_exited[0]; 364 pd->fd.exited_read = pipe_exited[0];
357 eina_file_close_on_exec(pd->fd.exited_write, EINA_TRUE); 365 eina_file_close_on_exec(pd->fd.exited_write, EINA_TRUE);
358 pd->fd.exited_write = pipe_exited[1]; 366 pd->fd.exited_write = pipe_exited[1];
@@ -360,7 +368,13 @@ _efl_exe_efl_task_run(Eo *obj EINA_UNUSED, Efl_Exe_Data *pd)
360 368
361 if (pd->flags & EFL_EXE_FLAGS_USE_STDIN) 369 if (pd->flags & EFL_EXE_FLAGS_USE_STDIN)
362 { 370 {
363 pipe(pipe_stdin); 371 ret = pipe(pipe_stdin);
372 if (EINA_UNLIKELY(ret != 0))
373 {
374 const int error = errno;
375 ERR("pipe() failed: %s", strerror(error));
376 return EINA_FALSE;
377 }
364 pd->fd.in = pipe_stdin[1]; 378 pd->fd.in = pipe_stdin[1];
365 fcntl(pd->fd.in, F_SETFL, O_NONBLOCK); 379 fcntl(pd->fd.in, F_SETFL, O_NONBLOCK);
366 eina_file_close_on_exec(pd->fd.in, EINA_TRUE); 380 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)
372 } 386 }
373 if (pd->flags & EFL_EXE_FLAGS_USE_STDOUT) 387 if (pd->flags & EFL_EXE_FLAGS_USE_STDOUT)
374 { 388 {
375 pipe(pipe_stdout); 389 ret = pipe(pipe_stdout);
390 if (EINA_UNLIKELY(ret != 0))
391 {
392 const int error = errno;
393 ERR("pipe() failed: %s", strerror(error));
394 return EINA_FALSE;
395 }
376 pd->fd.out = pipe_stdout[0]; 396 pd->fd.out = pipe_stdout[0];
377 fcntl(pd->fd.out, F_SETFL, O_NONBLOCK); 397 fcntl(pd->fd.out, F_SETFL, O_NONBLOCK);
378 eina_file_close_on_exec(pd->fd.out, EINA_TRUE); 398 eina_file_close_on_exec(pd->fd.out, EINA_TRUE);