if (p->cgroup) free((void*)*p->cgroup);
if (p->supgid) free(p->supgid);
if (p->supgrp) free(p->supgrp);
-#ifdef WITH_SYSTEMD
if (p->sd_mach) free(p->sd_mach);
if (p->sd_ouid) free(p->sd_ouid);
if (p->sd_seat) free(p->sd_seat);
if (p->sd_slice) free(p->sd_slice);
if (p->sd_unit) free(p->sd_unit);
if (p->sd_uunit) free(p->sd_uunit);
-#endif
#ifdef QUICK_THREADS
}
#endif
}
///////////////////////////////////////////////////////////////////////
-#ifdef OOMEM_ENABLE
static void oomscore2proc(const char* S, proc_t *restrict P)
{
sscanf(S, "%d", &P->oom_score);
{
sscanf(S, "%d", &P->oom_adj);
}
-#endif
///////////////////////////////////////////////////////////////////////
static const char *ns_names[] = {
}
}
-#ifdef WITH_SYSTEMD
static void sd2proc(proc_t *restrict p) {
+#ifdef WITH_SYSTEMD
char buf[64];
uid_t uid;
snprintf(buf, sizeof(buf), "%d", (int)uid);
p->sd_ouid = strdup(buf);
}
-
if (0 > sd_pid_get_session(p->tid, &p->sd_sess)) {
p->sd_sess = strdup("-");
p->sd_seat = strdup("-");
if (0 > sd_session_get_seat(p->sd_sess, &p->sd_seat))
p->sd_seat = strdup("-");
}
-
if (0 > sd_pid_get_slice(p->tid, &p->sd_slice))
p->sd_slice = strdup("-");
-
if (0 > sd_pid_get_unit(p->tid, &p->sd_unit))
p->sd_unit = strdup("-");
-
if (0 > sd_pid_get_user_unit(p->tid, &p->sd_uunit))
p->sd_uunit = strdup("-");
-}
+#else
+ p->sd_mach = strdup("?");
+ p->sd_ouid = strdup("?");
+ p->sd_seat = strdup("?");
+ p->sd_sess = strdup("?");
+ p->sd_slice = strdup("?");
+ p->sd_unit = strdup("?");
+ p->sd_uunit = strdup("?");
#endif
+}
///////////////////////////////////////////////////////////////////////
} else
p->cgroup = NULL;
-#ifdef OOMEM_ENABLE
if (unlikely(flags & PROC_FILLOOM)) {
if (likely(file2str(path, "oom_score", &ub) != -1))
oomscore2proc(ub.buf, p);
if (likely(file2str(path, "oom_adj", &ub) != -1))
oomadj2proc(ub.buf, p);
}
-#endif
if (unlikely(flags & PROC_FILLNS)) // read /proc/#/ns/*
ns2proc(path, p);
-#ifdef WITH_SYSTEMD
if (unlikely(flags & PROC_FILLSYSTEMD)) // get sd-login.h stuff
sd2proc(p);
-#endif
if (unlikely(flags & PROC_FILL_LXC)) // value the lxc name
p->lxcname = lxc_containers(path);
} else
t->cgroup = NULL;
-#ifdef WITH_SYSTEMD
if (unlikely(flags & PROC_FILLSYSTEMD)) // get sd-login.h stuff
sd2proc(t);
-#endif
if (unlikely(flags & PROC_FILL_LXC)) // value the lxc name
t->lxcname = lxc_containers(path);
if (t->supgid) free(t->supgid);
t->supgid = p->supgid;
t->supgrp = p->supgrp;
-#ifdef WITH_SYSTEMD
t->sd_mach = p->sd_mach;
t->sd_ouid = p->sd_ouid;
t->sd_seat = p->sd_seat;
t->sd_slice = p->sd_slice;
t->sd_unit = p->sd_unit;
t->sd_uunit = p->sd_uunit;
-#endif
t->lxcname = p->lxcname;
MK_THREAD(t);
}
#endif
-#ifdef OOMEM_ENABLE
if (unlikely(flags & PROC_FILLOOM)) {
if (likely(file2str(path, "oom_score", &ub) != -1))
oomscore2proc(ub.buf, t);
if (likely(file2str(path, "oom_adj", &ub) != -1))
oomadj2proc(ub.buf, t);
}
-#endif
if (unlikely(flags & PROC_FILLNS)) // read /proc/#/task/#/ns/*
ns2proc(path, t);
tpgid, // stat terminal process group id
exit_signal, // stat might not be SIGCHLD
processor; // stat current (or most recent?) CPU
-#ifdef OOMEM_ENABLE
int
oom_score, // oom_score (badness for OOM killer)
oom_adj; // oom_adj (adjustment to OOM score)
-#endif
long
ns[NUM_NS]; // (ns subdir) inode number of namespaces
-#ifdef WITH_SYSTEMD
char
*sd_mach, // n/a systemd vm/container name
*sd_ouid, // n/a systemd session owner uid
*sd_slice, // n/a systemd slice unit
*sd_unit, // n/a systemd system unit id
*sd_uunit; // n/a systemd user unit id
-#endif
const char
*lxcname; // n/a lxc container name
} proc_t;