#ifdef OOMEM_ENABLE
if (unlikely(flags & PROC_FILLOOM)) {
if (likely(file2str(path, "oom_score", sbuf, sizeof sbuf) != -1))
- oomscore2proc(sbuf, p);
+ oomscore2proc(sbuf, t);
if (likely(file2str(path, "oom_adj", sbuf, sizeof sbuf) != -1))
- oomadj2proc(sbuf, p);
+ oomadj2proc(sbuf, t);
}
#endif
pgrp, // stat process group id
session, // stat session id
nlwp, // stat,status number of threads, or 0 if no clue
- tgid, // (special) task group ID, the POSIX PID (see also: tid)
+ tgid, // (special) thread group ID, the POSIX PID (see also: tid)
tty, // stat full device number of controlling terminal
euid, egid, // stat(),status effective
ruid, rgid, // status real
return 0; \
}
-/* fast version, for values which either:
+/* fast versions, for values which either:
* a. differ by no more than 0x7fffffff
* b. only need to be grouped same w/ same
*/
static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
return (int)(P->NAME) - (int)(Q->NAME); \
}
+#define CMP_SMALL2(NAME,WHAT) \
+static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
+ return (int)(P->WHAT) - (int)(Q->WHAT); \
+}
CMP_INT(rtprio)
CMP_SMALL(sched)
CMP_INT(sgid)
CMP_INT(fuid)
CMP_INT(fgid)
-CMP_SMALL(tid)
-CMP_SMALL(tgid)
+CMP_SMALL2(procs,tgid)
+CMP_SMALL2(tasks,tid)
CMP_SMALL(ppid)
CMP_SMALL(pgrp)
CMP_SMALL(session)
* ( determinations are made in display.c, we mostly deal with results ) */
static int pr_args(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf;
- unsigned flags;
- int rightward=max_rightward;
+ int rightward = max_rightward;
+ int fh = forest_helper(outbuf);
+
+ endp += fh;
+ rightward -= fh;
- if(forest_prefix){
- int fh = forest_helper(outbuf);
- endp += fh;
- rightward -= fh;
- }
if(pp->cmdline && !bsd_c_option)
endp += escaped_copy(endp, *pp->cmdline, OUTBUF_SIZE, &rightward);
else
* ( determinations are made in display.c, we mostly deal with results ) */
static int pr_comm(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf;
- unsigned flags;
- int rightward=max_rightward;
+ int rightward = max_rightward;
+ int fh = forest_helper(outbuf);
+
+ endp += fh;
+ rightward -= fh;
- if(forest_prefix){
- int fh = forest_helper(outbuf);
- endp += fh;
- rightward -= fh;
- }
if(pp->cmdline && unix_f_option)
endp += escaped_copy(endp, *pp->cmdline, OUTBUF_SIZE, &rightward);
else
static int pr_fname(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf;
int rightward = max_rightward;
+ int fh = forest_helper(outbuf);
+
+ endp += fh;
+ rightward -= fh;
- if(forest_prefix){
- int fh = forest_helper(outbuf);
- endp += fh;
- rightward -= fh;
- }
if (rightward>8) /* 8=default, but forest maybe feeds more */
rightward = 8;
static int pr_pgid(char *restrict const outbuf, const proc_t *restrict const pp){
return snprintf(outbuf, COLWID, "%u", pp->pgrp);
}
-static int pr_pid(char *restrict const outbuf, const proc_t *restrict const pp){
- return snprintf(outbuf, COLWID, "%u", pp->tgid);
-}
static int pr_ppid(char *restrict const outbuf, const proc_t *restrict const pp){
return snprintf(outbuf, COLWID, "%u", pp->ppid);
}
//////////////////////////////////////////////////////////////////////////////////
-// TID tid LWP lwp SPID spid
-static int pr_thread(char *restrict const outbuf, const proc_t *restrict const pp){
+// PID pid, TGID tgid
+static int pr_procs(char *restrict const outbuf, const proc_t *restrict const pp){
+ return snprintf(outbuf, COLWID, "%u", pp->tgid);
+}
+// LWP lwp, SPID spid, TID tid
+static int pr_tasks(char *restrict const outbuf, const proc_t *restrict const pp){
return snprintf(outbuf, COLWID, "%u", pp->tid);
}
// thcount THCNT
{"lstart", "STARTED", pr_lstart, sr_nop, 24, 0, XXX, ET|RIGHT},
{"luid", "LUID", pr_nop, sr_nop, 5, 0, LNX, ET|RIGHT}, /* login ID */
{"luser", "LUSER", pr_nop, sr_nop, 8, USR, LNX, ET|USER}, /* login USER */
-{"lwp", "LWP", pr_thread, sr_tid, 5, 0, SUN, TO|PIDMAX|RIGHT},
+{"lwp", "LWP", pr_tasks, sr_tasks, 5, 0, SUN, TO|PIDMAX|RIGHT},
{"m_drs", "DRS", pr_drs, sr_drs, 5, MEM, LNx, PO|RIGHT},
{"m_dt", "DT", pr_nop, sr_dt, 4, MEM, LNx, PO|RIGHT},
{"m_lrs", "LRS", pr_nop, sr_lrs, 5, MEM, LNx, PO|RIGHT},
{"pending", "PENDING", pr_sig, sr_nop, 9, 0, BSD, ET|SIGNAL}, /*sig*/
{"pgid", "PGID", pr_pgid, sr_pgrp, 5, 0, U98, PO|PIDMAX|RIGHT},
{"pgrp", "PGRP", pr_pgid, sr_pgrp, 5, 0, LNX, PO|PIDMAX|RIGHT},
-{"pid", "PID", pr_pid, sr_tgid, 5, 0, U98, PO|PIDMAX|RIGHT},
+{"pid", "PID", pr_procs, sr_procs, 5, 0, U98, PO|PIDMAX|RIGHT},
{"pmem", "%MEM", pr_pmem, sr_nop, 4, 0, XXX, PO|RIGHT}, /*%mem*/
{"poip", "-", pr_nop, sr_nop, 1, 0, BSD, AN|RIGHT},
{"policy", "POL", pr_class, sr_sched, 3, 0, DEC, TO|LEFT},
{"sigmask", "BLOCKED", pr_sigmask, sr_nop, 9, 0, XXX, TO|SIGNAL}, /*blocked*/
{"size", "SZ", pr_swapable, sr_swapable, 5, 0, SCO, PO|RIGHT},
{"sl", "SL", pr_nop, sr_nop, 3, 0, XXX, AN|RIGHT},
-{"spid", "SPID", pr_thread, sr_tid, 5, 0, SGI, TO|PIDMAX|RIGHT},
+{"spid", "SPID", pr_tasks, sr_tasks, 5, 0, SGI, TO|PIDMAX|RIGHT},
{"stackp", "STACKP", pr_stackp, sr_start_stack, 8, 0, LNX, PO|RIGHT}, /*start_stack*/
{"start", "STARTED", pr_start, sr_nop, 8, 0, XXX, ET|RIGHT},
{"start_code", "S_CODE", pr_nop, sr_start_code, 8, 0, LNx, PO|RIGHT},
{"taskid", "TASKID", pr_nop, sr_nop, 5, 0, SUN, TO|PIDMAX|RIGHT}, // is this a thread ID?
{"tdev", "TDEV", pr_nop, sr_nop, 4, 0, XXX, AN|RIGHT},
{"thcount", "THCNT", pr_nlwp, sr_nlwp, 5, 0, AIX, PO|RIGHT},
-{"tid", "TID", pr_thread, sr_tid, 5, 0, AIX, TO|PIDMAX|RIGHT},
+{"tgid", "TGID", pr_procs, sr_procs, 5, 0, LNX, PO|PIDMAX|RIGHT},
+{"tid", "TID", pr_tasks, sr_tasks, 5, 0, AIX, TO|PIDMAX|RIGHT},
{"time", "TIME", pr_time, sr_nop, 8, 0, U98, ET|RIGHT}, /*cputime*/ /* was 6 wide */
{"timeout", "TMOUT", pr_nop, sr_nop, 5, 0, LNX, AN|RIGHT}, // 2.0.xx era
{"tmout", "TMOUT", pr_nop, sr_nop, 5, 0, LNX, AN|RIGHT}, // 2.0.xx era
.br
.B ps\ axo\ stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
.br
-.B ps\ \-eopid,tt,user,fname,tmout,f,wchan
+.B ps\ \-Ao\ pid,tt,user,fname,tmout,f,wchan
.TP
Print only the process IDs of syslogd:
.B ps\ \-C\ syslogd\ \-o\ pid=
T}
lwp LWP T{
-lwp (light weight process, or thread) ID of the lwp being reported.
+light weight process (thread) ID of the dispatchable entity
(alias\ \fBspid\fR,\ \fBtid\fR).
+See \fBtid\fR for additional information.
T}
maj_flt MAJFLT T{
T}
pid PID T{
-process\ ID number of the process.
+a number representing the process ID
+(alias\ \fBtgid\fR).
T}
pmem %MEM T{
See \fBvsz\fR and \fBrss\fR.
T}
+tgid TGID T{
+a number representing the thread group to which a task
+belongs (alias\ \fBpid\fR).
+It is the process ID of the thread group leader.
+T}
+
thcount THCNT T{
see \fBnlwp\fR. (alias\ \fBnlwp\fR).
number of kernel threads owned by the process.
T}
tid TID T{
-see\ \fBlwp\fR. (alias\ \fBlwp\fR).
+the unique number representing a dispatacable entity
+(alias\ \fBlwp\fR,\ \fBspid\fR).
+This value may also appear as: a process ID (pid);
+a process group ID (pgrp);
+a session ID for the session leader (sid);
+a thread group ID for the thread group leader (tgid);
+and a tty process group ID for the process group leader (tpgid).
T}
time TIME T{
17.\fB PID \*(Em Process Id \fR
The task's unique process ID, which periodically wraps, though never
restarting at zero.
+In kernel terms, it is a dispatchable entity defined by a 'task_struct'.
This value may also be used as: a process group ID (\*(Xa PGRP);
a session ID for the session leader (\*(Xa SID);
+a thread group ID for the thread group leader (\*(Xa TGID);
and a TTY process group ID for the process group leader (\*(Xa TPGID).
.TP 4
The non-resident portion of a task's address space.
.TP 4
-31.\fB TIME \*(Em \*(PU Time \fR
+31.\fB TGID \*(Em Thread Group Id \fR
+The ID of the thread group to which a task belongs.
+It is the PID of the thread group leader.
+In kernel terms, it represents those tasks that share an 'mm_struct'.
+
+.TP 4
+32.\fB TIME \*(Em \*(PU Time \fR
Total \*(PU time the task has used since it started.
When 'Cumulative mode' is \*O, each process is listed with the \*(Pu
time that it and its dead children have used.
\*(XC 'S' \*(CI for additional information regarding this mode.
.TP 4
-32.\fB TIME+ \*(Em \*(PU Time, hundredths \fR
+33.\fB TIME+ \*(Em \*(PU Time, hundredths \fR
The same as 'TIME', but reflecting more granularity through hundredths
of a second.
.TP 4
-33.\fB TPGID \*(Em Tty Process Group Id \fR
+34.\fB TPGID \*(Em Tty Process Group Id \fR
The process group ID of the foreground process for the connected tty,
or -1 if a process is not connected to a terminal.
By convention, this value equals the process ID (\*(Xa PID) of the
the process group leader (\*(Xa PGRP).
.TP 4
-34.\fB TTY \*(Em Controlling Tty \fR
+35.\fB TTY \*(Em Controlling Tty \fR
The name of the controlling terminal.
This is usually the device (serial port, pty, etc.) from which the
process was started, and which it uses for input or output.
you'll see '?' displayed.
.TP 4
-35.\fB UID \*(Em User Id \fR
+36.\fB UID \*(Em User Id \fR
The\fI effective\fR user ID of the task's owner.
.TP 4
-36.\fB USER \*(Em User Name \fR
+37.\fB USER \*(Em User Name \fR
The\fI effective\fR user name of the task's owner.
.TP 4
-37.\fB VIRT \*(Em Virtual Memory Size (kb) \fR
+38.\fB VIRT \*(Em Virtual Memory Size (kb) \fR
The total amount of \*(MV used by the task.
It includes all code, data and shared libraries plus pages that have been
swapped out and pages that have been mapped but not used.
.TP 4
-38.\fB WCHAN \*(Em Sleeping in Function \fR
+39.\fB WCHAN \*(Em Sleeping in Function \fR
Depending on the availability of the kernel link map ('System.map'), this
field will show the name or the address of the kernel function in which the
task is currently sleeping.
SCB_NUM1(SID, session)
SCB_NUMx(STA, state)
SCB_NUM1(SWP, vm_swap)
+SCB_NUMx(TGD, tgid)
SCB_NUMx(THD, nlwp)
// also serves TM2 !
static int SCB_NAME(TME) (const proc_t **P, const proc_t **Q) {
{ "SUSER ", "%-8.8s ", -1, -1, SF(USN), L_OUSER, "Saved User Name" },
{ " GID ", "%5d ", -1, -1, SF(GID), L_NONE, "Group Id" },
{ "GROUP ", "%-8.8s ", -1, -1, SF(GRP), L_EGROUP, "Group Name" },
- { " PGRP ", "%5d ", -1, -1, SF(PGD), L_stat, "Process Group Id" },
+ { NULL, NULL, -1, -1, SF(PGD), L_stat, "Process Group Id" },
{ "TTY ", "%-8.8s ", 8, -1, SF(TTY), L_stat, "Controlling Tty" },
- { "TPGID ", "%5d ", -1, -1, SF(TPG), L_stat, "Tty Process Grp Id" },
- { " SID ", "%5d ", -1, -1, SF(SID), L_stat, "Session Id" },
+ { NULL, NULL, -1, -1, SF(TPG), L_stat, "Tty Process Grp Id" },
+ { NULL, NULL, -1, -1, SF(SID), L_stat, "Session Id" },
{ " PR ", "%3d ", -1, -1, SF(PRI), L_stat, "Priority" },
{ " NI ", "%3d ", -1, -1, SF(NCE), L_stat, "Nice Value" },
{ "nTH ", "%3d ", -1, -1, SF(THD), L_EITHER, "Number of Threads" },
// next 3 entries as P_CMD/P_WCH: '.head' must be same length -- they share varcolsz
{ "CGROUPS ", NULL, -1, -1, SF(CGR), L_CGROUP, "Control Groups" },
{ "SUPGIDS ", NULL, -1, -1, SF(SGD), L_status, "Supp Groups IDs" },
- { "SUPGRPS ", NULL, -1, -1, SF(SGN), L_SUPGRP, "Supp Groups Names" }
+ { "SUPGRPS ", NULL, -1, -1, SF(SGN), L_SUPGRP, "Supp Groups Names" },
+ { NULL, NULL, -1, -1, SF(TGD), L_status, "Thread Group Id" }
#ifdef OOMEM_ENABLE
#define L_oom PROC_FILLOOM
,{ "Adj ", "%3d ", -1, -1, SF(OOA), L_oom, "oom_adjustment (2^X)" }
* ( xPRFX has pos 2 & 10 for 'extending' when at minimums )
*
* The first 4 screen rows are reserved for explanatory text.
- * Thus, with our current 38 fields, a maximum of 6 columns and
+ * Thus, with our current 39 fields, a maximum of 6 columns and
* 1 space between columns, a tty will still remain useable under
* these extremes:
* rows cols displayed
* ---- ---- ------------------
- * 11 66 xPRFX only (w/ room for +4)
- * 11 198 full xPRFX + xSUFX (w/ room for +4)
- * 23 22 xPRFX only
- * 23 66 full xPRFX + xSUFX
+ * 11 66 xPRFX only (w/ room for +3)
+ * 11 198 full xPRFX + xSUFX (w/ room for +3)
+ * 24 22 xPRFX only (w/ room for +1)
+ * 24 66 full xPRFX + xSUFX (w/ room for +1)
* ( if not, the user deserves our most cryptic messages )
*/
static void display_fields (int focus, int extend) {
static void zap_fieldstab (void) {
static char fmts_pid[8];
static char fmts_cpu[8];
+ static int once;
unsigned digits;
char buf[8];
+ if (once) goto always;
+
Fieldstab[P_PID].head = " PID ";
Fieldstab[P_PID].fmts = "%5d ";
Fieldstab[P_PPD].head = " PPID ";
Fieldstab[P_PPD].fmts = "%5d ";
+ Fieldstab[P_PGD].head = " PGRP ";
+ Fieldstab[P_PGD].fmts = "%5d ";
+ Fieldstab[P_SID].head = " SID ";
+ Fieldstab[P_SID].fmts = "%5d ";
+ Fieldstab[P_TGD].head = " TGID ";
+ Fieldstab[P_TGD].fmts = "%5d ";
+ Fieldstab[P_TPG].head = "TPGID ";
+ Fieldstab[P_TPG].fmts = "%5d ";
if (5 < (digits = get_pid_digits())) {
if (10 < digits) error_exit("failed pid size test");
snprintf(fmts_pid, sizeof(fmts_pid), "%%%uu ", digits);
Fieldstab[P_PID].fmts = fmts_pid;
Fieldstab[P_PPD].head = " PPID " + 10 - digits;
Fieldstab[P_PPD].fmts = fmts_pid;
+ Fieldstab[P_PGD].head = " PGRP " + 10 - digits;
+ Fieldstab[P_PGD].fmts = fmts_pid;
+ Fieldstab[P_SID].head = " SID " + 10 - digits;
+ Fieldstab[P_SID].fmts = fmts_pid;
+ Fieldstab[P_TGD].head = " TGID " + 10 - digits;
+ Fieldstab[P_TGD].fmts = fmts_pid;
+ Fieldstab[P_TPG].head = " TPGID " + 10 - digits;
+ Fieldstab[P_TPG].fmts = fmts_pid;
}
+ once = 1;
+ /*** hotplug_acclimated ***/
+always:
Fieldstab[P_CPN].head = "P ";
Fieldstab[P_CPN].fmts = "%1d ";
if (1 < (digits = (unsigned)snprintf(buf, sizeof(buf), "%u", (unsigned)Cpu_tot))) {
mem_secs = cpu_secs = 0;
time(&cur_secs);
+ /*** hotplug_acclimated ***/
if (3 <= cur_secs - mem_secs) {
meminfo();
mem_secs = cur_secs;
}
#ifndef PRETEND4CPUS
+ /*** hotplug_acclimated ***/
if (300 <= cur_secs - cpu_secs) {
cpuinfo();
cpu_secs = cur_secs;
case P_SWP:
makeCOL(scale_num(p->vm_swap, w, s));
break;
+ case P_TGD:
+ makeCOL(p->tgid);
+ break;
case P_THD:
makeCOL(p->nlwp);
break;
P_MEM, P_VRT, P_SWP, P_RES, P_COD, P_DAT, P_SHR,
P_FL1, P_FL2, P_DRT,
P_STA, P_CMD, P_WCH, P_FLG, P_CGR,
- P_SGD, P_SGN,
+ P_SGD, P_SGN, P_TGD,
#ifdef OOMEM_ENABLE
P_OOA, P_OOM,
#endif