diff options
author | 2016-04-28 11:04:59 +0000 | |
---|---|---|
committer | 2016-04-28 11:27:55 +0000 | |
commit | e33cf0fb5306ad52d0066128a85bcd3b2e3f2ac8 (patch) | |
tree | a32a5fd756635b74979b43f77fc29d5a8d9956f4 | |
parent | 750656430d4a67b988ea8a9b14753617574b9874 (diff) |
*really* make server mode on Windows work.
This is still fallout from a bad merge I did yesterday.
More progress towards #930.
--
MOS_MIGRATED_REVID=121006319
-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); |