Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Dec 1997 18:15:48 GMT
From:      j@bug.fe.up.pt
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/5340: /usr/bin/ps does not work as expected
Message-ID:  <199712181815.SAA05059@bug.fe.up.pt>
Resent-Message-ID: <199712181820.KAA09914@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         5340
>Category:       bin
>Synopsis:       /usr/bin/ps shows 'con' in TT but it should show 'co'
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 18 10:20:00 PST 1997
>Last-Modified:
>Originator:     Jorge Goncalves
>Organization:
>Release:        FreeBSD 2.2-971214-SNAP i386
>Environment:

All FreeBSD releases as I know. 

>Description:

The ps program does not show 'co' when programs are running in the console
but it shows 'con' and the man page states:

     tt      An abbreviation for the pathname of the controlling terminal, if
             any.  The abbreviation consists of the two letters following
             ``/dev/tty'', or, for the console, ``co''.  This is followed by a
             ``-'' if the process can no longer reach that controlling termi-
             nal (i.e., it has been revoked).

>How-To-Repeat:

Some programs run using the console like squid, but it might also be 
recreated by running at getty on the console (change /etc/ttys):

	console "/usr/libexec/getty Pc"         cons25  on  secure

and then logging in using that virtual console ans issuing a ps:

  PID  TT  STAT      TIME COMMAND
  219  con Is     0:00.24 -tcsh (tcsh)

>Fix:
	
I am including a patch that corrects the problem. Hey, core team members,
apply this patch or change the code to behave as it is reported by the 
man page.

--- bin/ps/print.c.orig Thu Dec 18 17:26:37 1997
+++ bin/ps/print.c      Thu Dec 18 17:38:28 1997
@@ -337,8 +337,8 @@
        else {
                if (strncmp(ttname, "tty", 3) == 0 ||
                    strncmp(ttname, "cua", 3) == 0)
-                       ttname += 3;
-               (void)printf("%*.*s%c", v->width-1, v->width-1, ttname,
+                       ttname += 3; 
+               (void)printf(" %*.*s%c", v->width-2, v->width-2, ttname,
                        KI_EPROC(k)->e_flag & EPROC_CTTY ? ' ' : '-');
        }
 }

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712181815.SAA05059>