提交 c9c2763d 编写于 作者: sangshuduo's avatar sangshuduo

[TD-2705] fix: provide cmdline info when a shutdown signal received.

上级 a1328f4c
......@@ -160,7 +160,7 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
syslog(LOG_INFO, "Shut down signal is %d", signum);
syslog(LOG_INFO, "Shutting down TDengine service...");
// clean the system.
dInfo("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid);
dInfo("shut down signal is %d, sender PID:%d cmdline:%s", signum, sigInfo->si_pid, taosGetCmdlineByPID(sigInfo->si_pid));
// protect the application from receive another signal
struct sigaction act = {{0}};
......
......@@ -32,6 +32,7 @@ void taosPrintOsInfo();
int taosSystem(const char * cmd) ;
void taosKillSystem();
bool taosGetSystemUid(char *uid);
char *taosGetCmdlineByPID(int pid);
// TAOS_OS_FUNC_SYSINFO_CORE
void taosSetCoreDump();
......
......@@ -39,4 +39,22 @@ void osInit() {
strcpy(tsDnodeDir, "");
strcpy(tsMnodeDir, "");
strcpy(tsOsName, "Linux");
}
\ No newline at end of file
}
char cmdline[1024];
char *taosGetCmdlineByPID(int pid)
{
sprintf(cmdline, "/proc/%d/cmdline",pid);
FILE* f = fopen(cmdline,"r");
if(f){
size_t size;
size = fread(cmdline, sizeof(char), 1024, f);
if(size>0){
if('\n'==cmdline[size-1])
cmdline[size-1]='\0';
}
fclose(f);
}
return cmdline;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册