Improve subprocess behavior in tinc start command.
When invoking tincd, tinc start currently uses the execvp() function, which doesn't behave well in a console as the console displays a new prompt before the subprocess finishes (which makes me suspect the exit value is not handled at all). This new code uses spawnvp() instead, which seems like a better fit.
This commit is contained in:
parent
b22499668a
commit
ea12a0fb06
1 changed files with 6 additions and 3 deletions
|
@ -829,9 +829,12 @@ static int cmd_start(int argc, char *argv[]) {
|
||||||
nargv[nargc++] = argv[i];
|
nargv[nargc++] = argv[i];
|
||||||
|
|
||||||
#ifdef HAVE_MINGW
|
#ifdef HAVE_MINGW
|
||||||
execvp(c, nargv);
|
int status = spawnvp(_P_WAIT, c, nargv);
|
||||||
fprintf(stderr, "Error starting %s: %s\n", c, strerror(errno));
|
if (status == -1) {
|
||||||
return 1;
|
fprintf(stderr, "Error starting %s: %s\n", c, strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
#else
|
#else
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if(pid == -1) {
|
if(pid == -1) {
|
||||||
|
|
Loading…
Reference in a new issue