From 876aff85847d28194748cbba326cfeb6beb249d4 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Tue, 13 Jun 2017 00:00:00 -0500 Subject: [PATCH] library: correct the #define FALSE_THREADS, api Awhile back, that former QUICK_THREADS #define evolved into the development (only) FALSE_THREADS which can be used to ensure a 'duplicate ENUM' convention is output when certain string fields can't be easily duplicated. Unfortunately, that original implementation was marred with zeros being displayed for /proc/$$/meminfo fields in all the child threads for a multi-threaded process. So this commit corrects that zero memory field buglet. Reference(s): . QUICK_THREADS becomes FALSE_THREADS commit c546d9dd4409ee11cd466c99a820a3b5dadfe3f4 Signed-off-by: Jim Warner --- proc/readproc.c | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/proc/readproc.c b/proc/readproc.c index 9f4bdb34..6ca96d0e 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -989,11 +989,9 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric MK_THREAD(t); #endif -#ifndef FALSE_THREADS if (flags & PROC_FILLMEM) // read /proc/#/task/#statm if (file2str(path, "statm", &ub) != -1) statm2proc(ub.buf, t); -#endif if (flags & PROC_FILLSTATUS) { // read /proc/#/task/#/status if (file2str(path, "status", &ub) != -1) { @@ -1029,10 +1027,6 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric #ifdef FALSE_THREADS if (!p) { - if (flags & PROC_FILLMEM) - if (file2str(path, "statm", &ub) != -1) - statm2proc(ub.buf, t); - if (flags & PROC_FILLSUPGRP) supgrps_from_supgids(t); #endif @@ -1056,31 +1050,22 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric #ifdef FALSE_THREADS } else { - if (t != p) { - t->size = p->size; - t->resident = p->resident; - t->share = p->share; - t->trs = p->trs; - t->lrs = p->lrs; - t->drs = p->drs; - t->dt = p->dt; - t->cmdline = NULL; - t->cmdline_v = NULL; - t->environ = NULL; - t->environ_v = NULL; - t->cgname = NULL; - t->cgroup = NULL; - t->cgroup_v = NULL; - t->supgid = NULL; - t->supgrp = NULL; - t->sd_mach = NULL; - t->sd_ouid = NULL; - t->sd_seat = NULL; - t->sd_sess = NULL; - t->sd_slice = NULL; - t->sd_unit = NULL; - t->sd_uunit = NULL; - } + t->cmdline = NULL; + t->cmdline_v = NULL; + t->environ = NULL; + t->environ_v = NULL; + t->cgname = NULL; + t->cgroup = NULL; + t->cgroup_v = NULL; + t->supgid = NULL; + t->supgrp = NULL; + t->sd_mach = NULL; + t->sd_ouid = NULL; + t->sd_seat = NULL; + t->sd_sess = NULL; + t->sd_slice = NULL; + t->sd_unit = NULL; + t->sd_uunit = NULL; } #endif -- 2.40.0