mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
my_system: cleanup and propagate exitstatus
Origin commit data
------------------
Branch: ni/coolstream
Commit: e1df8ebafd
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2013-03-24 (Sun, 24 Mar 2013)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -103,7 +103,7 @@ int my_system(int argc, const char *arg, ...)
|
|||||||
case -1: /* can't vfork */
|
case -1: /* can't vfork */
|
||||||
perror("vfork");
|
perror("vfork");
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto out;
|
break;
|
||||||
case 0: /* child process */
|
case 0: /* child process */
|
||||||
for(i = 3; i < maxfd; i++)
|
for(i = 3; i < maxfd; i++)
|
||||||
close(i);
|
close(i);
|
||||||
@@ -111,21 +111,17 @@ int my_system(int argc, const char *arg, ...)
|
|||||||
perror("my_system setsid");
|
perror("my_system setsid");
|
||||||
if (execvp(argv[0], (char * const *)argv))
|
if (execvp(argv[0], (char * const *)argv))
|
||||||
{
|
{
|
||||||
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;
|
ret = -errno;
|
||||||
|
if (errno != ENOENT) /* don't complain if argv[0] only does not exist */
|
||||||
|
fprintf(stderr, "ERROR: my_system \"%s\": %m\n", argv[0]);
|
||||||
}
|
}
|
||||||
_exit (0); // terminate c h i l d proces s only
|
_exit(ret); // terminate c h i l d proces s only
|
||||||
default: /* parent returns to calling process */
|
default: /* parent returns to calling process */
|
||||||
|
waitpid(pid, &childExit, 0);
|
||||||
|
if (WEXITSTATUS(childExit) != 0)
|
||||||
|
ret = (signed char)WEXITSTATUS(childExit);
|
||||||
break;
|
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);
|
va_end(args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user