check for daemon pid existence before trying to connect to the control socket, and clean up stale files otherwise.

This commit is contained in:
Sean McVeigh 2016-05-21 17:25:18 -04:00
parent 9d0e86683c
commit 4314df644e

View file

@ -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;