From: Sean McVeigh Date: Sat, 21 May 2016 21:25:18 +0000 (-0400) Subject: check for daemon pid existence before trying to connect to the control socket, and... X-Git-Tag: release-1.1pre15~72 X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=4314df644e22778a554ca1760941a2bfae08bce2 check for daemon pid existence before trying to connect to the control socket, and clean up stale files otherwise. --- diff --git a/src/tincctl.c b/src/tincctl.c index e42ec2cc..39a11d31 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;