From a3f537f4d5b9db236ec67881c8b4fe4edbb80502 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 30 Jan 2021 18:34:39 +0800 Subject: [PATCH] [TD-2891] : get process cmdline by pid on mac. --- src/os/src/darwin/darwinSysInfo.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/os/src/darwin/darwinSysInfo.c b/src/os/src/darwin/darwinSysInfo.c index 0eb784e9f0..5b42b6b0f6 100644 --- a/src/os/src/darwin/darwinSysInfo.c +++ b/src/os/src/darwin/darwinSysInfo.c @@ -18,6 +18,9 @@ #include "tconfig.h" #include "tglobal.h" #include "tulog.h" +#include +#include + static void taosGetSystemTimezone() { // get and set default timezone @@ -103,8 +106,18 @@ int taosSystem(const char *cmd) { void taosSetCoreDump() {} +char cmdline[1024]; + char *taosGetCmdlineByPID(int pid) { - return "[not supported yet]"; + + errno = 0; + + if (proc_pidpath(pid, cmdline, sizeof(cmdline)) <= 0) { + fprintf(stderr, "PID is %d, %s", pid, strerror(errno)); + return strerror(errno); + } + + return cmdline; } bool taosGetSystemUid(char *uid) { -- GitLab