Merge pull request #5091 from taosdata/feature/sangshuduo/TD-2891-get-cmdline-by-pid-on-mac

[TD-2891] <feature>: get process cmdline by pid on mac.
This commit is contained in:
Shengliang Guan 2021-02-01 09:27:29 +08:00 committed by GitHub
commit da8d2fe495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -18,6 +18,9 @@
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include <errno.h>
#include <libproc.h>
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) {