From 232dc6954ebfc7b49e11211364814bc9de153e7d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 9 Mar 2013 18:08:23 +0100 Subject: [PATCH] my_system: return errno, silence trivial error message Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d77e54fcd60e4a93ae2e38b25c87ae776e927244 Author: Stefan Seyfried Date: 2013-03-09 (Sat, 09 Mar 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 9b348c317..637fd295f 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -102,7 +102,8 @@ int my_system(int argc, const char *arg, ...) { case -1: /* can't vfork */ perror("vfork"); - return -1; + ret = -errno; + goto out; case 0: /* child process */ for(i = 3; i < maxfd; i++) close(i); @@ -110,17 +111,21 @@ int my_system(int argc, const char *arg, ...) perror("my_system setsid"); if (execvp(argv[0], (char * const *)argv)) { - std::string txt = "ERROR: my_system \"" + (std::string) argv[0] + "\""; - perror(txt.c_str()); - ret = -1; + if (errno != ENOENT) { /* don't complain if argv[0] only does not exist */ + std::string txt = "ERROR: my_system \"" + (std::string) argv[0] + "\""; + perror(txt.c_str()); + } + ret = -errno; } _exit (0); // terminate c h i l d proces s only default: /* parent returns to calling process */ break; } + /* it is probably pure luck that ret gets propagated back from child to parent */ waitpid(pid, &childExit, 0); if(childExit != 0) ret = childExit; + out: va_end(args); return ret; }