X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=9f9df6f656e1aba603be92dd93eb12542df9bfb6;hb=ab13c14a1480561bb9f59ccfbbd6045e0484ce9c;hp=e42ec2cc81ccebb72709dac737856c5bdb64cfb8;hpb=ab5f4cbdc65cbc55062b36a6c11482c217884fe8;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index e42ec2cc..9f9df6f6 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -718,6 +718,13 @@ bool connect_tincd(bool verbose) { } fclose(f); + if ((pid == 0) || (kill(pid, 0) && (errno == ESRCH))) { + fprintf(stderr, "Could not find tincd running at pid %d\n", pid); + /* clean up the stale socket and pid file */ + unlink(pidfilename); + unlink(unixsocketname); + return false; + } #ifndef HAVE_MINGW struct sockaddr_un sa; @@ -1384,7 +1391,7 @@ static int cmd_pid(int argc, char *argv[]) { return 1; } - if(!connect_tincd(true) && !pid) + if(!connect_tincd(true) || !pid) return 1; printf("%d\n", pid);