From 6b7e4f5f52b530c2bedaba2c2ddbedce7821e0e2 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 11 Jun 2020 09:22:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=90=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=B7=AF=E5=BE=84=E5=9B=BA=E5=AE=9A=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/Process.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/server/Process.cpp b/server/Process.cpp index 10ff1e59..7a5f7c18 100644 --- a/server/Process.cpp +++ b/server/Process.cpp @@ -70,19 +70,18 @@ void Process::run(const string &cmd, const string &log_file_tmp) { } fclose(fp); #else - string log_file; - if (log_file_tmp.empty()) { - //未指定子进程日志文件时,重定向至/dev/null - log_file = "/dev/null"; - } else { - log_file = StrPrinter << log_file_tmp << "." << getpid(); - } - _pid = fork(); if (_pid < 0) { throw std::runtime_error(StrPrinter << "fork child process failed,err:" << get_uv_errmsg()); } if (_pid == 0) { + string log_file; + if (log_file_tmp.empty()) { + //未指定子进程日志文件时,重定向至/dev/null + log_file = "/dev/null"; + } else { + log_file = StrPrinter << log_file_tmp << "." << getpid(); + } //子进程关闭core文件生成 struct rlimit rlim = {0, 0}; setrlimit(RLIMIT_CORE, &rlim); @@ -132,6 +131,13 @@ void Process::run(const string &cmd, const string &log_file_tmp) { exit(ret); } + string log_file; + if (log_file_tmp.empty()) { + //未指定子进程日志文件时,重定向至/dev/null + log_file = "/dev/null"; + } else { + log_file = StrPrinter << log_file_tmp << "." << _pid; + } InfoL << "start child process " << _pid << ", log file:" << log_file; #endif // _WIN32 }