summaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
authorJinWang An <jinwang.an@samsung.com>2021-12-28 10:01:55 +0900
committerJinWang An <jinwang.an@samsung.com>2021-12-28 10:01:55 +0900
commit251aa3b4092071250ad7d50333b8846f5e34a997 (patch)
treed4f14f2c27eb25c245e786d856aaac0ff5749b0b /print.c
parent87a741891d5e52c324ed5d956c04eab8d2714ad8 (diff)
downloadlsof-87224ee24d940eef8b6e6eb1ea3eff033482c806.tar.gz
lsof-87224ee24d940eef8b6e6eb1ea3eff033482c806.tar.bz2
lsof-87224ee24d940eef8b6e6eb1ea3eff033482c806.zip
Imported Upstream version 4.90upstream/4.90
Diffstat (limited to 'print.c')
-rw-r--r--print.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/print.c b/print.c
index 6d227bc..f661766 100644
--- a/print.c
+++ b/print.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: print.c,v 1.55 2013/01/02 17:14:59 abe Exp $";
+static char *rcsid = "$Id: print.c,v 1.56 2018/02/14 14:20:14 abe Exp $";
#endif
@@ -678,8 +678,10 @@ print_file()
PIDTTL);
#if defined(HASTASKS)
- if (TaskPrtFl)
- (void) printf(" %*s", TidColW, TIDTTL);
+ if (TaskPrtTid)
+ (void) printf(" %*s", TaskTidColW, TASKTIDTTL);
+ if (TaskPrtCmd)
+ (void) printf(" %-*.*s", TaskCmdColW, TaskCmdColW, TASKCMDTTL);
#endif /* defined(HASTASKS) */
#if defined(HASZONES)
@@ -766,20 +768,35 @@ print_file()
#if defined(HASTASKS)
/*
- * Size or print task ID.
+ * Size or print task ID and command name.
*/
if (!PrPass) {
+ if ((cp = Lp->tcmd)) {
+ len = safestrlen(cp, 2);
+ if (TaskCmdLim && (len > TaskCmdLim))
+ len = TaskCmdLim;
+ if (len > TaskCmdColW)
+ TaskCmdColW = len;
+ TaskPrtCmd = 1;
+ }
if (Lp->tid) {
(void) snpf(buf, sizeof(buf), "%d", Lp->tid);
- if ((len = strlen(buf)) > TidColW)
- TidColW = len;
- TaskPrtFl = 1;
+ if ((len = strlen(buf)) >TaskTidColW)
+ TaskTidColW = len;
+ TaskPrtTid = 1;
+ }
+ } else {
+ if (TaskPrtTid) {
+ if (Lp->tid)
+ (void) printf(" %*d", TaskTidColW, Lp->tid);
+ else
+ (void) printf(" %*s", TaskTidColW, "");
+ }
+ if (TaskPrtCmd) {
+ cp = Lp->tcmd ? Lp->tcmd : "";
+ printf(" ");
+ safestrprtn(cp, TaskCmdColW, stdout, 2);
}
- } else if (TaskPrtFl) {
- if (Lp->tid)
- (void) printf(" %*d", TidColW, Lp->tid);
- else
- (void) printf(" %*s", TidColW, "");
}
#endif /* defined(HASTASKS) */
@@ -1279,7 +1296,7 @@ print_init()
*/
PrPass = (Ffield || Fterse) ? 1 : 0;
LastPid = -1;
- TaskPrtFl = 0;
+ TaskPrtCmd = TaskPrtTid = 0;
/*
* Size columns by their titles.
*/
@@ -1301,7 +1318,8 @@ print_init()
SzOffColW = strlen(SZOFFTTL);
#if defined(HASTASKS)
- TidColW = strlen(TIDTTL);
+ TaskCmdColW = strlen(TASKCMDTTL);
+ TaskTidColW = strlen(TASKTIDTTL);
#endif /* defined(HASTASKS) */
TypeColW = strlen(TYPETTL);