Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Dec 2001 05:29:16 -0800 (PST)
From:      Dimitri Lommers <dimitri@hinttech.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/33275: ps(1) should ignore termwidth when output is not to a tty (patch)
Message-ID:  <200112281329.fBSDTGR51108@freefall.freebsd.org>

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

>Number:         33275
>Category:       bin
>Synopsis:       ps(1) should ignore termwidth when output is not to a tty (patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 28 05:30:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dimitri Lommers
>Release:        4.3-RELEASE
>Organization:
Hinttech Internetwork Technologies
>Environment:
ps.c version:
$FreeBSD: src/bin/ps/ps.c,v 1.30.2.2 2001/01/23 15:08:37 asmodai Exp $

>Description:
      When ps(1) is called and output is not to a terminal, it should
not limit the line length to the size of the terminal it was called from.
This problem prevents i.e. 'ps aux | grep <something>' from working
if the output is larger than the (x)terminal window size.
>How-To-Repeat:
      
>Fix:
# diff -c ps.c.org ps.c
*** ps.c.org    Tue Jan 23 16:08:37 2001
--- ps.c        Fri Dec 28 14:51:22 2001
***************
*** 130,142 ****
  
        (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]);
--- 130,141 ----
  
        (void) setlocale(LC_ALL, "");
  
!       if (isatty(STDOUT_FILENO))
!               if ((ioctl(STDOUT_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]);
***************
*** 266,275 ****
                        dropgid = 1;
                        break;
                case 'w':
!                       if (wflag)
!                               termwidth = UNLIMITED;
!                       else if (termwidth < 131)
!                               termwidth = 131;
                        wflag++;
                        break;
                case 'x':
--- 265,275 ----
                        dropgid = 1;
                        break;
                case 'w':
!                       if (termwidth != UNLIMITED)
!                               if (wflag)
!                                       termwidth = UNLIMITED;
!                               else if (termwidth < 131)
!                                       termwidth = 131;
                        wflag++;
                        break;
                case 'x':


--- UUENCODED PATCH: ---

begin 644 patch
M*BHJ('!S+F,N;W)G"51U92!*86X@,C,@,38Z,#@Z,S<@,C`P,0HM+2T@<',N
M8PE&<FD@1&5C(#(X(#$T.C4Q.C(R(#(P,#$**BHJ*BHJ*BHJ*BHJ*BHJ"BHJ
M*B`Q,S`L,30R("HJ*BH*("`*("`)*'9O:60I('-E=&QO8V%L92A,0U]!3$PL
M("(B*3L*("`*(2`):68@*"AI;V-T;"A35$1/551?1DE,14Y/+"!424]#1U=)
M3E-:+"`H8VAA<B`J*29W<RD@/3T@+3$@)B8*(2`)("`@("!I;V-T;"A35$1%
M4E)?1DE,14Y/+"!424]#1U=)3E-:+"`H8VAA<B`J*29W<RD@/3T@+3$@)B8*
M(2`)("`@("!I;V-T;"A35$1)3E]&24Q%3D\L("!424]#1U=)3E-:+"`H8VAA
M<B`J*29W<RD@/3T@+3$I('Q\"B$@"2`@("`@=W,N=W-?8V]L(#T](#`I"B$@
M"0ET97)M=VED=&@@/2`W.3L*("`)96QS90HA(`D)=&5R;7=I9'1H(#T@=W,N
M=W-?8V]L("T@,3L*("`*("`):68@*&%R9V,@/B`Q*0H@(`D)87)G=ELQ72`]
M(&ML=61G95]O;&1P<U]O<'1I;VYS*&%R9W9;,5TI.PHM+2T@,3,P+#$T,2`M
M+2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unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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