Commit 4d5d8e26 authored by ericliu's avatar ericliu

bugfix: pid file may be overwritten

parent 88bf6106
...@@ -1669,7 +1669,7 @@ void Server::PutPidFileIfNeeded() { ...@@ -1669,7 +1669,7 @@ void Server::PutPidFileIfNeeded() {
return; return;
} }
} }
int fd = open(_options.pid_file.c_str(), O_WRONLY | O_CREAT, 0666); int fd = open(_options.pid_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) { if (fd < 0) {
LOG(WARNING) << "Fail to open " << _options.pid_file; LOG(WARNING) << "Fail to open " << _options.pid_file;
_options.pid_file.clear(); _options.pid_file.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment