diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/cpp/blaze.cc | 6 | ||||
-rw-r--r-- | src/main/cpp/blaze_util_mingw.cc | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index a5c35e302a..63afc7bd60 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -906,7 +906,8 @@ static bool ConnectToServer(BlazeServer *server, bool start) { globals->server_pid = GetServerPid(server_dir); if (globals->server_pid == -1) { pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, - "can't get server pid from connection"); + "can't get PID of existing server (server dir=%s)", + server_dir.c_str()); } return true; } @@ -941,7 +942,8 @@ static bool ConnectToServer(BlazeServer *server, bool start) { globals->server_pid = GetServerPid(server_dir); if (globals->server_pid == -1) { pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, - "can't get pid of fresh server from connection"); + "can't get pid of fresh server from connection (dir=%s)", + server_dir.c_str()); } return true; } diff --git a/src/main/cpp/blaze_util_mingw.cc b/src/main/cpp/blaze_util_mingw.cc index 136068d601..bdb8362b2b 100644 --- a/src/main/cpp/blaze_util_mingw.cc +++ b/src/main/cpp/blaze_util_mingw.cc @@ -289,7 +289,7 @@ static bool DaemonizeOnWindows() { } int ExecuteDaemon(const string& exe, const std::vector<string>& args_vector, - const string& daemon_output, const string& pid_file) { + const string& daemon_output, const string& server_dir) { if (DaemonizeOnWindows()) { // We are the client process // TODO(lberki): -1 is only an in-band signal that tells that there is no @@ -364,7 +364,13 @@ int ExecuteDaemon(const string& exe, const std::vector<string>& args_vector, CloseHandle(pipe_write); CloseHandle(pipe_read); - WriteFile(ToString(GetProcessId(processInfo.hProcess)), pid_file); + string pid_string = ToString(getpid()); + string pid_file = blaze_util::JoinPath(server_dir, ServerPidFile()); + if (!WriteFile(pid_string, pid_file)) { + // Not a lot we can do if this fails + fprintf(stderr, "Cannot write PID file %s\n", pid_file.c_str()); + } + CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); |