未验证 提交 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) { ...@@ -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, "Shut down signal is %d", signum);
syslog(LOG_INFO, "Shutting down TDengine service..."); syslog(LOG_INFO, "Shutting down TDengine service...");
// clean the system. // 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 // protect the application from receive another signal
struct sigaction act = {{0}}; struct sigaction act = {{0}};
......
...@@ -32,6 +32,7 @@ void taosPrintOsInfo(); ...@@ -32,6 +32,7 @@ void taosPrintOsInfo();
int taosSystem(const char * cmd) ; int taosSystem(const char * cmd) ;
void taosKillSystem(); void taosKillSystem();
bool taosGetSystemUid(char *uid); bool taosGetSystemUid(char *uid);
char *taosGetCmdlineByPID(int pid);
// TAOS_OS_FUNC_SYSINFO_CORE // TAOS_OS_FUNC_SYSINFO_CORE
void taosSetCoreDump(); void taosSetCoreDump();
......
...@@ -39,4 +39,22 @@ void osInit() { ...@@ -39,4 +39,22 @@ void osInit() {
strcpy(tsDnodeDir, ""); strcpy(tsDnodeDir, "");
strcpy(tsMnodeDir, ""); strcpy(tsMnodeDir, "");
strcpy(tsOsName, "Linux"); 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.
先完成此消息的编辑!
想要评论请 注册