From 4314df644e22778a554ca1760941a2bfae08bce2 Mon Sep 17 00:00:00 2001 From: Sean McVeigh Date: Sat, 21 May 2016 17:25:18 -0400 Subject: [PATCH] check for daemon pid existence before trying to connect to the control socket, and clean up stale files otherwise. --- src/tincctl.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; -- 2.20.1