未验证 提交 26eabcd9 编写于 作者: H huili 提交者: GitHub

Merge pull request #4866 from taosdata/hotfix/sangshuduo/TD-2705-shutdown-signal-cmdline-info

[TD-2705] fix: provide cmdline info when a shutdown signal received.
......@@ -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();
......
......@@ -40,3 +40,21 @@ void osInit() {
strcpy(tsMnodeDir, "");
strcpy(tsOsName, "Linux");
}
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.
先完成此消息的编辑!
想要评论请 注册