mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 14:45:55 +08:00
修复子进程日志路径固定的问题
This commit is contained in:
parent
9c646d1316
commit
6b7e4f5f52
@ -70,19 +70,18 @@ void Process::run(const string &cmd, const string &log_file_tmp) {
|
|||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
#else
|
#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();
|
_pid = fork();
|
||||||
if (_pid < 0) {
|
if (_pid < 0) {
|
||||||
throw std::runtime_error(StrPrinter << "fork child process failed,err:" << get_uv_errmsg());
|
throw std::runtime_error(StrPrinter << "fork child process failed,err:" << get_uv_errmsg());
|
||||||
}
|
}
|
||||||
if (_pid == 0) {
|
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文件生成
|
//子进程关闭core文件生成
|
||||||
struct rlimit rlim = {0, 0};
|
struct rlimit rlim = {0, 0};
|
||||||
setrlimit(RLIMIT_CORE, &rlim);
|
setrlimit(RLIMIT_CORE, &rlim);
|
||||||
@ -132,6 +131,13 @@ void Process::run(const string &cmd, const string &log_file_tmp) {
|
|||||||
exit(ret);
|
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;
|
InfoL << "start child process " << _pid << ", log file:" << log_file;
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user