From ec3ecac715b299766c101be92caf8b7cffb2a8b5 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 31 Aug 2017 17:52:40 +0100 Subject: ps: add parent process id as a supported column --- procps/ps.c | 6 +++--- win32/process.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/procps/ps.c b/procps/ps.c index 742d1715e..a8541e6cf 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -257,12 +257,12 @@ static void func_pid(char *buf, int size, const procps_status_t *ps) sprintf(buf, "%*u", size, ps->pid); } -#if !ENABLE_PLATFORM_MINGW32 static void func_ppid(char *buf, int size, const procps_status_t *ps) { sprintf(buf, "%*u", size, ps->ppid); } +#if !ENABLE_PLATFORM_MINGW32 static void func_pgid(char *buf, int size, const procps_status_t *ps) { sprintf(buf, "%*u", size, ps->pgid); @@ -393,8 +393,8 @@ static const ps_out_t out_spec[] = { { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, #endif { 5 , "pid" ,"PID" ,func_pid ,PSSCAN_PID }, -#if !ENABLE_PLATFORM_MINGW32 { 5 , "ppid" ,"PPID" ,func_ppid ,PSSCAN_PPID }, +#if !ENABLE_PLATFORM_MINGW32 { 5 , "pgid" ,"PGID" ,func_pgid ,PSSCAN_PGID }, #endif #if ENABLE_FEATURE_PS_TIME @@ -556,7 +556,7 @@ static void format_process(const procps_status_t *ps) # define SELINUX_O_PREFIX "label," # define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") #elif ENABLE_PLATFORM_MINGW32 -# define DEFAULT_O_STR ("pid,comm") +# define DEFAULT_O_STR ("pid,ppid,comm") #else # define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") #endif diff --git a/win32/process.c b/win32/process.c index 192eeab56..c0ff78105 100644 --- a/win32/process.c +++ b/win32/process.c @@ -362,6 +362,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags UNUSED_PAR } sp->pid = pe.th32ProcessID; + sp->ppid = pe.th32ParentProcessID; safe_strncpy(sp->comm, pe.szExeFile, COMM_LEN); return sp; } -- cgit v1.2.3-55-g6feb