Index: lsof_4.89_src/store.c
===================================================================
--- lsof_4.89_src.orig/store.c
+++ lsof_4.89_src/store.c
@@ -43,6 +43,8 @@ static char *rcsid = "$Id: store.c,v 1.4
  * Global storage definitions
  */
 
+int AllProc = 1;		/* all processes are selected (default) */
+
 #if	defined(HASBLKDEV)
 struct l_dev *BDevtp = (struct l_dev *)NULL;
 				/* block device table pointer */
@@ -238,6 +240,7 @@ struct fieldsel FieldSel[] = {
 };
 
 int Hdr = 0;			/* header print status */
+int IgnTasks = 0;		/* ignore tasks when non-zero */
 char *InodeFmt_d = (char *) NULL;
 				/* INODETYPE decimal printf specification */
 char *InodeFmt_x = (char *) NULL;
@@ -323,8 +326,9 @@ int RptTm = 0;			/* repeat time -- set b
 struct l_dev **Sdev = (struct l_dev **)NULL;
 				/* pointer to Devtp[] pointers, sorted
 				 * by device */
-int Selall = 1;			/* all processes are selected (default) */
+int SelAll = 0;			/* SELALL flags, modified by IgnTasks */
 int Selflags = 0;		/* selection flags -- see SEL* in lsof.h */
+int SelProc = 0;		/* SELPROC flags, modified by IgnTasks */
 int Setgid = 0;			/* setgid state */
 int Selinet = 0;		/* select only Internet socket files */
 int Setuidroot = 0;		/* setuid-root state */
Index: lsof_4.89_src/proc.c
===================================================================
--- lsof_4.89_src.orig/proc.c
+++ lsof_4.89_src/proc.c
@@ -499,7 +499,7 @@ examine_lproc()
  *	o  listing is selected by an ANDed option set (not all options)
  *	   that includes a single PID selection -- this one.
  */
-	if ((Lp->sf & SELPID) && !Selall) {
+	if ((Lp->sf & SELPID) && !AllProc) {
 	    if ((Selflags == SELPID)
 	    ||  (Fand && (Selflags & SELPID))) {
 		sbp = 1;
@@ -649,7 +649,7 @@ is_file_sel(lp, lf)
 	}
 #endif	/* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */
 
-	if (Selall)
+	if (AllProc)
 	    return(1);
 	if (Fand && ((lf->sf & Selflags) != Selflags))
 	    return(0);
@@ -743,13 +743,13 @@ is_proc_excl(pid, pgid, uid, pss, sf)
  * network selections from the file flags, so that the tests in is_file_sel()
  * work as expected.
  */
-	if (Selall) {
+	if (AllProc) {
 	    *pss = PS_PRI;
 
 #if	defined(HASSECURITY) && defined(HASNOSOCKSECURITY)
-	    *sf = SELALL & ~(SELNA | SELNET);
+	    *sf = SelAll & ~(SELNA | SELNET);
 #else	/* !defined(HASSECURITY) || !defined(HASNOSOCKSECURITY) */
-	    *sf = SELALL;
+	    *sf = SelAll;
 #endif	/* defined(HASSECURITY) && defined(HASNOSOCKSECURITY) */
 
 	    return(0);
Index: lsof_4.89_src/main.c
===================================================================
--- lsof_4.89_src.orig/main.c
+++ lsof_4.89_src/main.c
@@ -190,7 +190,7 @@ main(argc, argv)
 #endif	/* defined(HASKOPT) */
 
 #if	defined(HASTASKS)
-	    "K",
+	    "K:",
 #else	/* !defined(HASTASKS) */
 	    "",
 #endif	/* defined(HASTASKS) */
@@ -591,10 +591,27 @@ main(argc, argv)
 #endif	/* defined(HASKOPT) */
 
 #if	defined(HASTASKS)
-		case 'K':
+	    case 'K':
+		if (!GOv || *GOv == '-' || *GOv == '+') {
 		    Ftask = 1;
+		    IgnTasks = 0;
 		    Selflags |= SELTASK;
-		    break;
+		    if (GOv) {
+			GOx1 = GObk[0];
+			GOx2 = GObk[1];
+		    }
+		} else {
+		    if (!strcasecmp(GOv, "i")) {
+			Ftask = 0;
+			IgnTasks = 1;
+			Selflags &= ~SELTASK;
+		   } else {
+			(void) fprintf(stderr,
+			    "%s: -K not followed by i (but by %s)\n", Pn, GOv);
+			err = 1;
+		   }
+		}
+		break;
 #endif	/* defined(HASTASKS) */
 
 	    case 'l':
@@ -981,6 +998,12 @@ main(argc, argv)
 		err = 1;
 	    }
 	}
+
+/*
+ * If IgnTasks is set, remove SELTASK from SelAll and SelProc.
+ */
+	SelAll = IgnTasks ? (SELALL & ~SELTASK) : SELALL;
+	SelProc = IgnTasks ? (SELPROC & ~SELTASK) : SELPROC;
 /*
  * Check for argument consistency.
  */
@@ -1159,12 +1182,12 @@ main(argc, argv)
 		    "%s: no select options to AND via -a\n", Pn);
 		usage(1, 0, 0);
 	    }
-	    Selflags = SELALL;
+	    Selflags = SelAll;
 	} else {
 	    if (GOx1 >= argc && (Selflags & (SELNA|SELNET)) != 0
 	    &&  (Selflags & ~(SELNA|SELNET)) == 0)
 		Selinet = 1;
-	    Selall = 0;
+	    AllProc = 0;
 	}
 /*
  * Get the device for DEVDEV_PATH.
Index: lsof_4.89_src/lsof.h
===================================================================
--- lsof_4.89_src.orig/lsof.h
+++ lsof_4.89_src/lsof.h
@@ -513,6 +513,8 @@ struct afsnode {			/* AFS pseudo-node st
 };
 # endif	/* defined(HAS_AFS) */
 
+extern int AllProc;
+
 # if	defined(HAS_STD_CLONE)
 struct clone {
 	int dx;			/* index of device entry in Devtp[] */
@@ -728,6 +730,7 @@ extern struct fieldsel FieldSel[];
 extern int Hdr;
 
 enum IDType {PGID, PID};
+extern int  IgnTasks;
 extern char *InodeFmt_d;
 extern char *InodeFmt_x;
 extern int LastPid;
@@ -1005,8 +1008,9 @@ extern int Procsrch;
 extern int PrPass;
 extern int RptTm;
 extern struct l_dev **Sdev;
-extern int Selall;
+extern int SelAll;
 extern int Selflags;
+extern int SelProc;
 extern int Setgid;
 extern int Selinet;
 extern int Setuidroot;
Index: lsof_4.89_src/lsof.8
===================================================================
--- lsof_4.89_src.orig/lsof.8
+++ lsof_4.89_src/lsof.8
@@ -10,7 +10,7 @@ lsof \- list open files
 .SH SYNOPSIS
 .B lsof
 [
-.B \-?abChKlnNOPRtUvVX
+.B \-?abChlnNOPRtUvVX
 ] [
 .BI -A " A"
 ] [
@@ -36,6 +36,8 @@ lsof \- list open files
 ] [
 .BI \-k " k"
 ] [
+.BI \-K " k"
+] [
 .BI +|\-L " [l]"
 ] [
 .BI +|\-m " m"
@@ -1019,7 +1021,7 @@ Here are some sample addresses:
 	:time \- either TCP, UDP or UDPLITE time service port
 .fi
 .TP \w'names'u+4
-.B \-K
+.B \-K " k"
 selects the listing of tasks (threads) of processes, on dialects
 where task (thread) reporting is supported.
 (If help output \- i.e., the output of the
@@ -1029,6 +1031,15 @@ or
 options \- shows this option, then task (thread) reporting is
 supported by the dialect.)
 .IP
+If
+.B \-K
+is followed by a value,
+.IR k ,
+it must be ``i''.  That causes
+.I lsof
+to ignore tasks, particularly in the default, list\-everything case
+when no other options are specified.
+.IP
 When
 .B \-K
 and
Index: lsof_4.89_src/dialects/hpux/pstat/dproc.c
===================================================================
--- lsof_4.89_src.orig/dialects/hpux/pstat/dproc.c
+++ lsof_4.89_src/dialects/hpux/pstat/dproc.c
@@ -212,7 +212,7 @@ gather_proc_info()
 	     * If only ORed process selection options have been specified,
 	     * enable conditional file skipping and socket file only checking.
 	     */
-		if ((Selflags & SELFILE) || !(Selflags & SELPROC))
+		if ((Selflags & SELFILE) || !(Selflags & SelProc))
 		    cckreg = ckscko = 0;
 		else
 		    cckreg = ckscko = 1;
@@ -247,7 +247,7 @@ gather_proc_info()
 	     * socket file only checking, based on the process' selection
 	     * status.
 	     */
-		ckscko = (sf & SELPROC) ? 0 : 1;
+		ckscko = (sf & SelProc) ? 0 : 1;
 	    }
 	    alloc_lproc((int)p->pst_pid, (int)p->pst_pgrp, (int)p->pst_ppid,
 			(UID_ARG)p->pst_uid, p->pst_ucomm, (int)pss, (int)sf);
Index: lsof_4.89_src/dialects/linux/dproc.c
===================================================================
--- lsof_4.89_src.orig/dialects/linux/dproc.c
+++ lsof_4.89_src/dialects/linux/dproc.c
@@ -252,7 +252,7 @@ gather_proc_info()
 	     * If only ORed process selection options have been specified,
 	     * enable conditional file skipping and socket file only checking.
 	     */
-		if ((Selflags & SELFILE) || !(Selflags & SELPROC))
+		if ((Selflags & SELFILE) || !(Selflags & SelProc))
 		    Cckreg = Ckscko = 0;
 		else
 		    Cckreg = Ckscko = 1;
@@ -307,7 +307,7 @@ gather_proc_info()
 	 * If task reporting is selected, check the tasks of the process first,
 	 * so that the "-p<PID> -aK" options work properly.
 	 */
-	    if ((Selflags & SELTASK)) {
+	    if (!IgnTasks && (Selflags & SELTASK)) {
 		(void) make_proc_path(pidpath, n, &taskpath, &taskpathl,
 				      "task");
 		tx = n + 4;
@@ -375,14 +375,14 @@ gather_proc_info()
 	/*
 	 * If the main process is a task and task selection has been specified
 	 * along with option ANDing, enter the main process temporarily as a
-	 * task,  so that the "-aK" option set lists the main process along
+	 * task, so that the "-aK" option set lists the main process along
 	 * with its tasks.
 	 */
 	    (void) make_proc_path(pidpath, n, &path, &pathl, "stat");
 	    if (((rv = read_id_stat(path, pid, &cmd, &ppid, &pgid)) >= 0) 
 	    &&   (rv != 1))
 	    {
-		tid = (Fand && ht && pidts && (Selflags & SELTASK)) ? pid : 0;
+		tid = (Fand && ht && pidts && !IgnTasks && (Selflags & SELTASK)) ? pid : 0;
 		if ((!process_id(pidpath, n, cmd, uid, pid, ppid, pgid, tid))
 		&&  tid)
 		{
@@ -854,7 +854,7 @@ process_id(idp, idpl, cmd, uid, pid, ppi
 	 * socket file only checking, based on the process' selection
 	 * status.
 	 */
-	    Ckscko = (sf & SELPROC) ? 0 : 1;
+	    Ckscko = (sf & SelProc) ? 0 : 1;
 	}
 	alloc_lproc(pid, pgid, ppid, uid, cmd, (int)pss, (int)sf);
 	Lp->tid = tid;
Index: lsof_4.89_src/dialects/freebsd/dproc.c
===================================================================
--- lsof_4.89_src.orig/dialects/freebsd/dproc.c
+++ lsof_4.89_src/dialects/freebsd/dproc.c
@@ -190,7 +190,7 @@ gather_proc_info()
 	     * If only ORed process selection options have been specified,
 	     * enable conditional file skipping and socket file only checking.
 	     */
-		if ((Selflags & SELFILE) || !(Selflags & SELPROC))
+		if ((Selflags & SELFILE) || !(Selflags & SelProc))
 		    cckreg = ckscko = 0;
 		else
 		    cckreg = ckscko = 1;
@@ -324,7 +324,7 @@ gather_proc_info()
 	     * socket file only checking, based on the process' selection
 	     * status.
 	     */
-		ckscko = (sf & SELPROC) ? 0 : 1;
+		ckscko = (sf & SelProc) ? 0 : 1;
 	    }
 	    alloc_lproc(p->P_PID, pgid, ppid, (UID_ARG)uid, p->P_COMM,
 		(int)pss, (int)sf);
Index: lsof_4.89_src/dialects/darwin/libproc/dproc.c
===================================================================
--- lsof_4.89_src.orig/dialects/darwin/libproc/dproc.c
+++ lsof_4.89_src/dialects/darwin/libproc/dproc.c
@@ -221,7 +221,7 @@ gather_proc_info()
 	     * If only ORed process selection options have been specified,
 	     * enable conditional file skipping and socket file only checking.
 	     */
-		if ((Selflags & SELFILE) || !(Selflags & SELPROC))
+		if ((Selflags & SELFILE) || !(Selflags & SelProc))
 		    cckreg = ckscko = 0;
 		else
 		    cckreg = ckscko = 1;
@@ -338,7 +338,7 @@ gather_proc_info()
 	     * socket file only checking, based on the process' selection
 	     * status.
 	     */
-		ckscko = (sf & SELPROC) ? 0 : 1;
+		ckscko = (sf & SelProc) ? 0 : 1;
 	    }
 	/*
 	 * Get root and current directory information.
Index: lsof_4.89_src/dialects/aix/dproc.c
===================================================================
--- lsof_4.89_src.orig/dialects/aix/dproc.c
+++ lsof_4.89_src/dialects/aix/dproc.c
@@ -409,7 +409,7 @@ gather_proc_info()
 	     * If only ORed process selection options have been specified,
 	     * enable conditional file skipping and socket file only checking.
 	     */
-		if ((Selflags & SELFILE) || !(Selflags & SELPROC))
+		if ((Selflags & SELFILE) || !(Selflags & SelProc))
 		    cckreg = ckscko = 0;
 		else
 		    cckreg = ckscko = 1;
@@ -537,7 +537,7 @@ gather_proc_info()
 	     * socket file only checking, based on the process' selection
 	     * status.
 	     */
-		ckscko = (sf & SELPROC) ? 0 : 1;
+		ckscko = (sf & SelProc) ? 0 : 1;
 	    }
 	    
 #else	/* AIXV>=4300 */
@@ -557,7 +557,7 @@ gather_proc_info()
 	     * socket file only checking, based on the process' selection
 	     * status.
 	     */
-		ckscko = (sf & SELPROC) ? 0 : 1;
+		ckscko = (sf & SelProc) ? 0 : 1;
 	    }
 	    if (!fds) {
 		if (!(fds = (struct FDSINFO *)malloc((MALLOC_S)FDSINFOSIZE)))
Index: lsof_4.89_src/usage.c
===================================================================
--- lsof_4.89_src.orig/usage.c
+++ lsof_4.89_src/usage.c
@@ -550,7 +550,9 @@ usage(xv, fh, version)
 	    col = print_in_col(col, buf);
 
 #if	defined(HASTASKS)
-	    col = print_in_col(col, "-K list tasKs (threads)");
+/* DEBUG           col = print_in_col(col, "-K list tasKs (threads)"); */
+            col = print_in_col(col, "-K [i] list|(i)gn tasKs");
+
 #endif	/* defined(HASTASKS) */
 
 	    col = print_in_col(col, "-l list UID numbers");
