diff options
author | Jason King <jason.king@joyent.com> | 2019-11-13 12:32:26 -0600 |
---|---|---|
committer | Jason King <jason.king@joyent.com> | 2019-11-14 16:00:52 -0600 |
commit | f21abddf5629122d5dd1aa759e5ec0f27610c188 (patch) | |
tree | b61973d4eb8d8cff1334101fdf60d49ad49948d7 /usr/src | |
parent | cb09bd3c63580aef9fe1999ae4e48a8a5b9cf55c (diff) | |
download | illumos-joyent-f21abddf5629122d5dd1aa759e5ec0f27610c188.tar.gz |
11963 Allow ptree(1) to wrap output
Reviewed by: Andrew Stormont <astormont@racktopsystems.com>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/ptools/ptree/ptree.c | 24 | ||||
-rw-r--r-- | usr/src/man/man1/ptree.1 | 14 |
2 files changed, 31 insertions, 7 deletions
diff --git a/usr/src/cmd/ptools/ptree/ptree.c b/usr/src/cmd/ptools/ptree/ptree.c index 83f9c3c7e1..82a32bf46c 100644 --- a/usr/src/cmd/ptools/ptree/ptree.c +++ b/usr/src/cmd/ptools/ptree/ptree.c @@ -90,6 +90,7 @@ static int aflag = 0; static int cflag = 0; static int gflag = 0; static int sflag = 0; +static int wflag = 0; static int zflag = 0; static zoneid_t zoneid; static char *match_svc; @@ -149,6 +150,8 @@ usage(void) (void) fprintf(stderr, " -s : print only processes with given service FMRI\n"); (void) fprintf(stderr, + " -w : allow lines to wrap instead of truncating\n"); + (void) fprintf(stderr, " -z : print only processes in given zone\n"); exit(2); } @@ -164,7 +167,7 @@ main(int argc, char **argv) ps_t *p; /* options */ - while ((opt = getopt(argc, argv, "acgs:z:")) != EOF) { + while ((opt = getopt(argc, argv, "acgs:wz:")) != EOF) { switch (opt) { case 'a': /* include children of process 0 */ aflag = 1; @@ -180,6 +183,9 @@ main(int argc, char **argv) sflag = 1; match_svc = parse_svc(optarg, &match_inst); break; + case 'w': + wflag = 1; + break; case 'z': /* only processes in given zone */ zflag = 1; zoneid = getzone(optarg); @@ -196,8 +202,10 @@ main(int argc, char **argv) if (errflg) usage(); - columns = get_termwidth(); - VERIFY3S(columns, >, 0); + if (!wflag) { + columns = get_termwidth(); + VERIFY3S(columns, >, 0); + } nps = 0; psize = 0; @@ -334,8 +342,14 @@ printone(ps_t *p, int level) if (p->done && !FAKEDPID0(p)) { indent = level * 2; - if ((n = columns - PIDWIDTH - indent - 2) < 0) - n = 0; + + if (wflag) { + n = strlen(p->psargs); + } else { + if ((n = columns - PIDWIDTH - indent - 2) < 0) + n = 0; + } + printlines(p, level); if (p->pid >= 0) { (void) printf("%-*d %.*s\n", PIDWIDTH, (int)p->pid, n, diff --git a/usr/src/man/man1/ptree.1 b/usr/src/man/man1/ptree.1 index d603584e4c..c812b38612 100644 --- a/usr/src/man/man1/ptree.1 +++ b/usr/src/man/man1/ptree.1 @@ -4,12 +4,12 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PTREE 1 "Oct 30, 2019" +.TH PTREE 1 "Nov 13, 2019" .SH NAME ptree \- print process trees .SH SYNOPSIS .nf -\fB/usr/bin/ptree\fR [\fB-a\fR] [\fB-c\fR] [\fB-g\fR] [\fB-s\fR \fIsvc\fR] [\fB-z\fR \fIzone\fR] [\fIpid\fR | \fIuser\fR]... +\fB/usr/bin/ptree\fR [\fB-a\fR] [\fB-c\fR] [\fB-g\fR] [\fB-w\fR] [\fB-s\fR \fIsvc\fR] [\fB-z\fR \fIzone\fR] [\fIpid\fR | \fIuser\fR]... .fi .SH DESCRIPTION @@ -65,6 +65,16 @@ See \fBprocess\fR(4). .sp .ne 2 .na +\fB\fB-w\fR\fR +.ad +.RS 11n +Allow output lines to wrap. Normally output lines are truncated to the current +width of the terminal window. +.RE + +.sp +.ne 2 +.na \fB\fB-z\fR \fIzone\fR\fR .ad .RS 11n |