From owner-freebsd-bugs Fri Mar 16 12:10:15 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 1DD9D37B71C for ; Fri, 16 Mar 2001 12:10:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f2GKA2174657; Fri, 16 Mar 2001 12:10:02 -0800 (PST) (envelope-from gnats) Received: from cx420564-b.tucson1.az.home.com (cx420564-b.tucson1.az.home.com [24.21.112.225]) by hub.freebsd.org (Postfix) with ESMTP id 7666D37B718 for ; Fri, 16 Mar 2001 12:00:11 -0800 (PST) (envelope-from fracture@cx420564-b.tucson1.az.home.com) Received: (from fracture@localhost) by cx420564-b.tucson1.az.home.com (8.11.1/8.11.1) id f2GCpuk22673; Fri, 16 Mar 2001 12:51:56 GMT (envelope-from fracture) Message-Id: <200103161251.f2GCpuk22673@cx420564-b.tucson1.az.home.com> Date: Fri, 16 Mar 2001 12:51:56 GMT From: fracture@allusion.net Reply-To: fracture@allusion.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/25855: /bin/ps issue when output isn't to a tty Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 25855 >Category: bin >Synopsis: /bin/ps issue when output isn't to a tty >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Mar 16 12:10:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Jordan DeLong >Release: FreeBSD 4.2-RELEASE i386 >Organization: N/A >Environment: N/A >Description: When the output from /bin/ps is piped to another program, it limits it's output to a width of 79 cols. This causes problems with commands such as: ps aux | grep httpd because if the httpd part is past the 79 col mark, the grep wont find it. right now the way around this is to use ps wwaux | grep httpd but it doesn't make sense to have to specify terminal "width" if the output isn't to a terminal >How-To-Repeat: easiest way to repeat is to use the -e options so nothing will manage to be in the <79 cols for the grep to read it. so for instance: # ps eaxu | grep getty will not show anything. >Fix: this checks if the stdout is a tty before limiting the cols used diff -crN /usr/src/bin/ps/ps.c ps/ps.c *** /usr/src/bin/ps/ps.c Sat Jul 8 05:14:43 2000 --- ps/ps.c Fri Mar 16 10:56:18 2001 *************** *** 127,139 **** (void) setlocale(LC_ALL, ""); ! if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ! ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ! ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) || ! ws.ws_col == 0) ! termwidth = 79; ! else ! termwidth = ws.ws_col - 1; if (argc > 1) argv[1] = kludge_oldps_options(argv[1]); --- 127,143 ---- (void) setlocale(LC_ALL, ""); ! if (isatty(STDOUT_FILENO)) { ! if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ! ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ! ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) || ! ws.ws_col == 0) ! termwidth = 79; ! else ! termwidth = ws.ws_col - 1; ! } else { ! termwidth = UNLIMITED; ! } if (argc > 1) argv[1] = kludge_oldps_options(argv[1]); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message