bin/52489: [PATCH] ps tpt does not work

Jilles Tjoelker jilles at
Tue May 20 09:20:11 PDT 2003

>Number:         52489
>Category:       bin
>Synopsis:       [PATCH] ps tpt does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 20 09:20:08 PDT 2003
>Originator:     Jilles Tjoelker
>Release:        FreeBSD 4.8-RELEASE i386
MCGV Stack
System: FreeBSD 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Sat Apr 19 16:05:02 CEST 2003     jilles at  i386

The problem is present on a fairly recent 4.8-STABLE and 5.1-BETA as well.
The kludge in ps that changes 't' to 'T' at the end of argv[1] if there is no
minus does not check for a 't' option.

Note that ps Uroot did not work in FreeBSD 4.3-RELEASE, but works in
$ ps tpt
ps: /dev/ttypT: No such file or directory
Workaround: Use ps -tpt or ps t pt.

A possible fix is below.

--- ps-tkludge.patch begins here ---
--- /usr/src/bin/ps/ps.c.orig	Thu Jul  4 10:30:37 2002
+++ /usr/src/bin/ps/ps.c	Fri May 16 23:07:00 2003
@@ -619,7 +619,7 @@
 	 * option string, the remainder of the string is the argument to
 	 * that flag; do not modify that argument.
-	if (strcspn(s, "MNOoU") == len && *cp == 't' && *s != '-')
+	if (strcspn(s, "MNOoUt") >= len - 1 && *cp == 't' && *s != '-')
 		*cp = 'T';
 	else {
--- ps-tkludge.patch ends here ---

More information about the freebsd-bugs mailing list