From jilles@stack.nl  Tue May 20 09:19:54 2003
Return-Path: <jilles@stack.nl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E220037B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 20 May 2003 09:19:54 -0700 (PDT)
Received: from hexagon.stack.nl (hexagon.stack.nl [131.155.140.144])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 43D4043F75
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 20 May 2003 09:19:54 -0700 (PDT)
	(envelope-from jilles@stack.nl)
Received: by hexagon.stack.nl (Postfix, from userid 65534)
	id 313581C40; Tue, 20 May 2003 18:19:53 +0200 (CEST)
Received: from toad.stack.nl (toad.stack.nl [2001:610:1108:5010::135])
	by hexagon.stack.nl (Postfix) with ESMTP id 412CC1C4C
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 20 May 2003 18:19:48 +0200 (CEST)
Received: by toad.stack.nl (Postfix, from userid 1677)
	id 1AAEF9A; Tue, 20 May 2003 18:19:48 +0200 (CEST)
Message-Id: <20030520161948.1AAEF9A@toad.stack.nl>
Date: Tue, 20 May 2003 18:19:48 +0200 (CEST)
From: Jilles Tjoelker <jilles@stack.nl>
Reply-To: Jilles Tjoelker <jilles@stack.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] ps tpt does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         52489
>Category:       bin
>Synopsis:       [PATCH] bin/ps 'tpt' does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gad
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 20 09:20:08 PDT 2003
>Closed-Date:    Tue Jun 08 00:14:40 GMT 2004
>Last-Modified:  Tue Jun 08 00:14:40 GMT 2004
>Originator:     Jilles Tjoelker
>Release:        FreeBSD 4.8-RELEASE i386
>Organization:
MCGV Stack
>Environment:
System: FreeBSD xxx.xxx.xxx 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Sat Apr 19 16:05:02 CEST 2003     jilles@xxx.xxx.xxx:/usr/obj/usr/src/sys/JAGUAR  i386

The problem is present on a fairly recent 4.8-STABLE and 5.1-BETA as well.
>Description:
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
4.8-RELEASE.
>How-To-Repeat:
$ ps tpt
ps: /dev/ttypT: No such file or directory
>Fix:
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 ---
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gad 
Responsible-Changed-By: gad 
Responsible-Changed-When: Sat May 22 16:26:27 PDT 2004 
Responsible-Changed-Why:  
I'll look into this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52489 
State-Changed-From-To: open->closed 
State-Changed-By: gad 
State-Changed-When: Tue Jun 8 00:14:04 GMT 2004 
State-Changed-Why:  
A fix for this has been applied to 5.x-current, and has also been 
MFC'ed into 4.x-stable. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52489 
>Unformatted:
