tool patch - ps

Ulrich Windl (Ulrich.Windl@rz.uni-regensburg.de)
Wed, 22 May 1996 08:15:03 +0200


--Message-Boundary-30500
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

I have made a quick and dirty patch to fix the output of "ps -lax".
I'll attach the patch. Not a kernel issue, unless Linus changes some
of the new flags...

Ulrich

--Message-Boundary-30500
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'ps-patch'

DESCRIPTION OF DEFECT
Recent kernels use the new flag PF_USEDFPU (0x00100000) that breaks
the three digit format used for "ps -l".

FIX
This patch fixes the format of "ps -lax" for Linux 2.0.
The sulution chosen is to extend the length of the flags field to
six digits. As an alternative, the new flags can be set to zero
(commented).
(This patch has been made against procps-0.99a from the German
S.u.S.E. distribution; fuzz factors may apply.)

AUTHOR
Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>

Index: readproc.c
===================================================================
RCS file: /tmp/REPOS/procps/proc/readproc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- readproc.c 1996/05/21 18:08:36 1.1
+++ readproc.c 1996/05/21 19:12:32 1.2
@@ -92,6 +92,7 @@
}
if (linux_version_code < LINUX_VERSION(1,1,30) && P->tty != -1)
P->tty = 4*0x100 + P->tty; /* when tty wasn't full devno */
+/* P->flags &= 0x0fff; /* three digits */
}

void statm2proc(char* s, proc_t* P) {
Index: ps.c
===================================================================
RCS file: /tmp/REPOS/procps/ps.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ps.c 1996/05/21 18:08:34 1.1
+++ ps.c 1996/05/21 19:10:47 1.2
@@ -54,7 +54,7 @@
const char* header;
} mode[] = {
{ show_short, 0 , "Up", " PID TTY STAT TIME COMMAND" },
- { show_long, 'l', "Pp", " F UID PID PPID PRI NI SIZE RSS WCHAN STAT TTY TIME COMMAND" },
+ { show_long, 'l', "Pp", " F UID PID PPID PRI NI SIZE RSS WCHAN STAT TTY TIME COMMAND" },
{ show_user, 'u', "up", "USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND" },
{ show_jobs, 'j', "gPp"," PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND" },
{ show_sig, 's', "p", " UID PID SIGNAL BLOCKED IGNORED CATCHED STAT TTY TIME COMMAND" },
@@ -382,7 +382,7 @@
sprintf(wchanb, "%-9x", p->wchan);
else
sprintf(wchanb, "%-9.9s", wchan(p->wchan));
- sprintf(s, "%3x %5d %5d %5d %3d %2d %5d %5d %-10.10s %s %3s ",
+ sprintf(s, "%6x %5d %5d %5d %3d %3d %5d %5d %-10.10s %s %3s ",
p->flags, p->uid, p->pid, p->ppid, p->priority, p->nice,
p->vsize >> 10, p->rss * 4, wchanb, status2(p), p->ttyc);
}

--Message-Boundary-30500--