|
|
c00d7d |
diff -up ./lsof.8.ori ./lsof.8
|
|
|
c00d7d |
--- ./lsof.8.ori 2018-02-20 16:45:18.347856323 +0100
|
|
|
c00d7d |
+++ ./lsof.8 2018-02-20 16:45:26.204823914 +0100
|
|
|
c00d7d |
@@ -6,7 +6,7 @@ lsof \- list open files
|
|
|
c00d7d |
.SH SYNOPSIS
|
|
|
c00d7d |
.B lsof
|
|
|
c00d7d |
[
|
|
|
c00d7d |
-.B \-?abChKlnNOPRtUvVX
|
|
|
c00d7d |
+.B \-?abChlnNOPRtUvVX
|
|
|
c00d7d |
] [
|
|
|
c00d7d |
.BI -A " A"
|
|
|
c00d7d |
] [
|
|
|
c00d7d |
@@ -30,6 +30,8 @@ lsof \- list open files
|
|
|
c00d7d |
] [
|
|
|
c00d7d |
.BI \-k " k"
|
|
|
c00d7d |
] [
|
|
|
c00d7d |
+.BI \-K " k"
|
|
|
c00d7d |
+] [
|
|
|
c00d7d |
.BI +|\-L " [l]"
|
|
|
c00d7d |
] [
|
|
|
c00d7d |
.BI +|\-m " m"
|
|
|
c00d7d |
@@ -963,7 +965,7 @@ Here are some sample addresses:
|
|
|
c00d7d |
:time \- either TCP, UDP or UDPLITE time service port
|
|
|
c00d7d |
.fi
|
|
|
c00d7d |
.TP \w'names'u+4
|
|
|
c00d7d |
-.B \-K
|
|
|
c00d7d |
+.BI \-K " k"
|
|
|
c00d7d |
selects the listing of tasks (threads) of processes, on dialects
|
|
|
c00d7d |
where task (thread) reporting is supported.
|
|
|
c00d7d |
(If help output \- i.e., the output of the
|
|
|
c00d7d |
@@ -973,6 +975,15 @@ or
|
|
|
c00d7d |
options \- shows this option, then task (thread) reporting is
|
|
|
c00d7d |
supported by the dialect.)
|
|
|
c00d7d |
.IP
|
|
|
c00d7d |
+If
|
|
|
c00d7d |
+.B \-K
|
|
|
c00d7d |
+is followed by a value,
|
|
|
c00d7d |
+.IR k ,
|
|
|
c00d7d |
+it must be ``i''. That causes
|
|
|
c00d7d |
+.I lsof
|
|
|
c00d7d |
+to ignore tasks, particularly in the default, list\-everything case
|
|
|
c00d7d |
+when no other options are specified.
|
|
|
c00d7d |
+.IP
|
|
|
c00d7d |
When
|
|
|
c00d7d |
.B \-K
|
|
|
c00d7d |
and
|
|
|
c00d7d |
diff -up ./lsof.h.ori ./lsof.h
|
|
|
c00d7d |
--- ./lsof.h.ori 2018-02-19 17:41:00.082833606 +0100
|
|
|
c00d7d |
+++ ./lsof.h 2018-02-19 18:39:40.336086710 +0100
|
|
|
c00d7d |
@@ -491,6 +491,8 @@ struct afsnode { /* AFS pseudo-node st
|
|
|
c00d7d |
};
|
|
|
c00d7d |
# endif /* defined(HAS_AFS) */
|
|
|
c00d7d |
|
|
|
c00d7d |
+extern int AllProc;
|
|
|
c00d7d |
+
|
|
|
c00d7d |
# if defined(HAS_STD_CLONE)
|
|
|
c00d7d |
struct clone {
|
|
|
c00d7d |
int dx; /* index of device entry in Devtp[] */
|
|
|
c00d7d |
@@ -672,6 +674,7 @@ extern struct fieldsel FieldSel[];
|
|
|
c00d7d |
extern int Hdr;
|
|
|
c00d7d |
|
|
|
c00d7d |
enum IDType {PGID, PID};
|
|
|
c00d7d |
+extern int IgnTasks;
|
|
|
c00d7d |
extern char *InodeFmt_d;
|
|
|
c00d7d |
extern char *InodeFmt_x;
|
|
|
c00d7d |
extern int LastPid;
|
|
|
c00d7d |
@@ -938,8 +941,9 @@ extern int Procsrch;
|
|
|
c00d7d |
extern int PrPass;
|
|
|
c00d7d |
extern int RptTm;
|
|
|
c00d7d |
extern struct l_dev **Sdev;
|
|
|
c00d7d |
-extern int Selall;
|
|
|
c00d7d |
+extern int SelAll;
|
|
|
c00d7d |
extern int Selflags;
|
|
|
c00d7d |
+extern int SelProc;
|
|
|
c00d7d |
extern int Setgid;
|
|
|
c00d7d |
extern int Selinet;
|
|
|
c00d7d |
extern int Setuidroot;
|
|
|
c00d7d |
diff -up ./main.c.ori ./main.c
|
|
|
c00d7d |
--- ./main.c.ori 2018-02-19 17:20:33.058670928 +0100
|
|
|
c00d7d |
+++ ./main.c 2018-02-19 18:26:41.245793075 +0100
|
|
|
c00d7d |
@@ -181,7 +181,7 @@ main(argc, argv)
|
|
|
c00d7d |
#endif /* defined(HASKOPT) */
|
|
|
c00d7d |
|
|
|
c00d7d |
#if defined(HASTASKS)
|
|
|
c00d7d |
- "K",
|
|
|
c00d7d |
+ "K:",
|
|
|
c00d7d |
#else /* !defined(HASTASKS) */
|
|
|
c00d7d |
"",
|
|
|
c00d7d |
#endif /* defined(HASTASKS) */
|
|
|
c00d7d |
@@ -575,10 +575,27 @@ main(argc, argv)
|
|
|
c00d7d |
#endif /* defined(HASKOPT) */
|
|
|
c00d7d |
|
|
|
c00d7d |
#if defined(HASTASKS)
|
|
|
c00d7d |
- case 'K':
|
|
|
c00d7d |
+ case 'K':
|
|
|
c00d7d |
+ if (!GOv || *GOv == '-' || *GOv == '+') {
|
|
|
c00d7d |
Ftask = 1;
|
|
|
c00d7d |
+ IgnTasks = 0;
|
|
|
c00d7d |
Selflags |= SELTASK;
|
|
|
c00d7d |
- break;
|
|
|
c00d7d |
+ if (GOv) {
|
|
|
c00d7d |
+ GOx1 = GObk[0];
|
|
|
c00d7d |
+ GOx2 = GObk[1];
|
|
|
c00d7d |
+ }
|
|
|
c00d7d |
+ } else {
|
|
|
c00d7d |
+ if (!strcasecmp(GOv, "i")) {
|
|
|
c00d7d |
+ Ftask = 0;
|
|
|
c00d7d |
+ IgnTasks = 1;
|
|
|
c00d7d |
+ Selflags &= ~SELTASK;
|
|
|
c00d7d |
+ } else {
|
|
|
c00d7d |
+ (void) fprintf(stderr,
|
|
|
c00d7d |
+ "%s: -K not followed by i (but by %s)\n", Pn, GOv);
|
|
|
c00d7d |
+ err = 1;
|
|
|
c00d7d |
+ }
|
|
|
c00d7d |
+ }
|
|
|
c00d7d |
+ break;
|
|
|
c00d7d |
#endif /* defined(HASTASKS) */
|
|
|
c00d7d |
|
|
|
c00d7d |
case 'l':
|
|
|
c00d7d |
@@ -966,6 +983,11 @@ main(argc, argv)
|
|
|
c00d7d |
}
|
|
|
c00d7d |
}
|
|
|
c00d7d |
/*
|
|
|
c00d7d |
+ * If IgnTasks is set, remove SELTASK from SelAll and SelProc.
|
|
|
c00d7d |
+ */
|
|
|
c00d7d |
+ SelAll = IgnTasks ? (SELALL & ~SELTASK) : SELALL;
|
|
|
c00d7d |
+ SelProc = IgnTasks ? (SELPROC & ~SELTASK) : SELPROC;
|
|
|
c00d7d |
+/*
|
|
|
c00d7d |
* Check for argument consistency.
|
|
|
c00d7d |
*/
|
|
|
c00d7d |
if (Cmdnx && Cmdni) {
|
|
|
c00d7d |
@@ -1143,12 +1165,12 @@ main(argc, argv)
|
|
|
c00d7d |
"%s: no select options to AND via -a\n", Pn);
|
|
|
c00d7d |
usage(1, 0, 0);
|
|
|
c00d7d |
}
|
|
|
c00d7d |
- Selflags = SELALL;
|
|
|
c00d7d |
+ Selflags = SelAll;
|
|
|
c00d7d |
} else {
|
|
|
c00d7d |
if (GOx1 >= argc && (Selflags & (SELNA|SELNET)) != 0
|
|
|
c00d7d |
&& (Selflags & ~(SELNA|SELNET)) == 0)
|
|
|
c00d7d |
Selinet = 1;
|
|
|
c00d7d |
- Selall = 0;
|
|
|
c00d7d |
+ AllProc = 0;
|
|
|
c00d7d |
}
|
|
|
c00d7d |
/*
|
|
|
c00d7d |
* Get the device for DEVDEV_PATH.
|
|
|
c00d7d |
diff -up ./proc.c.ori ./proc.c
|
|
|
c00d7d |
--- ./proc.c.ori 2018-02-19 18:39:57.188006540 +0100
|
|
|
c00d7d |
+++ ./proc.c 2018-02-19 18:44:33.993689693 +0100
|
|
|
c00d7d |
@@ -498,7 +498,7 @@ examine_lproc()
|
|
|
c00d7d |
* o listing is selected by an ANDed option set (not all options)
|
|
|
c00d7d |
* that includes a single PID selection -- this one.
|
|
|
c00d7d |
*/
|
|
|
c00d7d |
- if ((Lp->sf & SELPID) && !Selall) {
|
|
|
c00d7d |
+ if ((Lp->sf & SELPID) && !AllProc) {
|
|
|
c00d7d |
if ((Selflags == SELPID)
|
|
|
c00d7d |
|| (Fand && (Selflags & SELPID))) {
|
|
|
c00d7d |
sbp = 1;
|
|
|
c00d7d |
@@ -648,7 +648,7 @@ is_file_sel(lp, lf)
|
|
|
c00d7d |
}
|
|
|
c00d7d |
#endif /* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */
|
|
|
c00d7d |
|
|
|
c00d7d |
- if (Selall)
|
|
|
c00d7d |
+ if (AllProc)
|
|
|
c00d7d |
return(1);
|
|
|
c00d7d |
if (Fand && ((lf->sf & Selflags) != Selflags))
|
|
|
c00d7d |
return(0);
|
|
|
c00d7d |
@@ -742,13 +742,13 @@ is_proc_excl(pid, pgid, uid, pss, sf)
|
|
|
c00d7d |
* network selections from the file flags, so that the tests in is_file_sel()
|
|
|
c00d7d |
* work as expected.
|
|
|
c00d7d |
*/
|
|
|
c00d7d |
- if (Selall) {
|
|
|
c00d7d |
+ if (AllProc) {
|
|
|
c00d7d |
*pss = PS_PRI;
|
|
|
c00d7d |
|
|
|
c00d7d |
#if defined(HASSECURITY) && defined(HASNOSOCKSECURITY)
|
|
|
c00d7d |
- *sf = SELALL & ~(SELNA | SELNET);
|
|
|
c00d7d |
+ *sf = SelAll & ~(SELNA | SELNET);
|
|
|
c00d7d |
#else /* !defined(HASSECURITY) || !defined(HASNOSOCKSECURITY) */
|
|
|
c00d7d |
- *sf = SELALL;
|
|
|
c00d7d |
+ *sf = SelAll;
|
|
|
c00d7d |
#endif /* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */
|
|
|
c00d7d |
|
|
|
c00d7d |
return(0);
|
|
|
c00d7d |
diff -up ./store.c.ori ./store.c
|
|
|
c00d7d |
--- ./store.c.ori 2018-02-19 18:39:50.532038205 +0100
|
|
|
c00d7d |
+++ ./store.c 2018-02-19 18:42:57.828147181 +0100
|
|
|
c00d7d |
@@ -43,6 +43,8 @@ static char *rcsid = "$Id: store.c,v 1.4
|
|
|
c00d7d |
* Global storage definitions
|
|
|
c00d7d |
*/
|
|
|
c00d7d |
|
|
|
c00d7d |
+int AllProc = 1; /* all processes are selected (default) */
|
|
|
c00d7d |
+
|
|
|
c00d7d |
#if defined(HASBLKDEV)
|
|
|
c00d7d |
struct l_dev *BDevtp = (struct l_dev *)NULL;
|
|
|
c00d7d |
/* block device table pointer */
|
|
|
c00d7d |
@@ -236,6 +238,7 @@ struct fieldsel FieldSel[] = {
|
|
|
c00d7d |
};
|
|
|
c00d7d |
|
|
|
c00d7d |
int Hdr = 0; /* header print status */
|
|
|
c00d7d |
+int IgnTasks = 0; /* ignore tasks when non-zero */
|
|
|
c00d7d |
char *InodeFmt_d = (char *) NULL;
|
|
|
c00d7d |
/* INODETYPE decimal printf specification */
|
|
|
c00d7d |
char *InodeFmt_x = (char *) NULL;
|
|
|
c00d7d |
@@ -320,8 +323,9 @@ int RptTm = 0; /* repeat time -- set b
|
|
|
c00d7d |
struct l_dev **Sdev = (struct l_dev **)NULL;
|
|
|
c00d7d |
/* pointer to Devtp[] pointers, sorted
|
|
|
c00d7d |
* by device */
|
|
|
c00d7d |
-int Selall = 1; /* all processes are selected (default) */
|
|
|
c00d7d |
+int SelAll = 0; /* SELALL flags, modified by IgnTasks */
|
|
|
c00d7d |
int Selflags = 0; /* selection flags -- see SEL* in lsof.h */
|
|
|
c00d7d |
+int SelProc = 0; /* SELPROC flags, modified by IgnTasks */
|
|
|
c00d7d |
int Setgid = 0; /* setgid state */
|
|
|
c00d7d |
int Selinet = 0; /* select only Internet socket files */
|
|
|
c00d7d |
int Setuidroot = 0; /* setuid-root state */
|
|
|
c00d7d |
diff -up ./dialects/linux/dproc.c.ori ./dialects/linux/dproc.c
|
|
|
c00d7d |
--- ./dialects/linux/dproc.c.ori 2018-02-21 14:32:56.779061847 +0100
|
|
|
c00d7d |
+++ ./dialects/linux/dproc.c 2018-02-21 16:10:53.896590180 +0100
|
|
|
c00d7d |
@@ -228,7 +228,7 @@ gather_proc_info()
|
|
|
c00d7d |
* If only ORed process selection options have been specified,
|
|
|
c00d7d |
* enable conditional file skipping and socket file only checking.
|
|
|
c00d7d |
*/
|
|
|
c00d7d |
- if ((Selflags & SELFILE) || !(Selflags & SELPROC))
|
|
|
c00d7d |
+ if ((Selflags & SELFILE) || !(Selflags & SelProc))
|
|
|
c00d7d |
Cckreg = Ckscko = 0;
|
|
|
c00d7d |
else
|
|
|
c00d7d |
Cckreg = Ckscko = 1;
|