From: Etienne Dechamps Date: Sat, 12 Jul 2014 17:53:25 +0000 (+0100) Subject: Improve subprocess behavior in tinc start command. X-Git-Tag: release-1.1pre11~61^2 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=ea12a0fb066793c316ccc9ef21444f092f74b4ba 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. --- diff --git a/src/tincctl.c b/src/tincctl.c index 12cffebc..f4379b7f 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -829,9 +829,12 @@ static int cmd_start(int argc, char *argv[]) { nargv[nargc++] = argv[i]; #ifdef HAVE_MINGW - execvp(c, nargv); - fprintf(stderr, "Error starting %s: %s\n", c, strerror(errno)); - return 1; + int status = spawnvp(_P_WAIT, c, nargv); + if (status == -1) { + fprintf(stderr, "Error starting %s: %s\n", c, strerror(errno)); + return 1; + } + return status; #else pid_t pid = fork(); if(pid == -1) {