]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: don't list kernel threads unless --threads is given
authorMasatake YAMATO <yamato@redhat.com>
Wed, 24 Jan 2024 00:05:47 +0000 (09:05 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 28 Jan 2024 17:11:21 +0000 (02:11 +0900)
misc-utils/lsfd.1.adoc
misc-utils/lsfd.c
tests/ts/lsfd/column-kthread

index 09c181655ad05e6e617315e248c9c976a82e8d5f..7e7534ef89099a6260b94409c46580549cd670c7 100644 (file)
@@ -653,11 +653,6 @@ List files opened in a QEMU virtual machine: ::
 # lsfd -Q '(COMMAND =~ ".\*qemu.*") and (FD >= 0)'
 ....
 
-Hide files associated to kernel threads: ::
-....
-# lsfd -Q '!KTHREAD'
-....
-
 List timerfd files expired within 0.5 seconds: ::
 ....
 # lsfd -Q '(TIMERFD.remaining < 0.5) and (TIMERFD.remaining > 0.0)'
index 2d04f4c4ab2ae71a13a2cea32605c74a876a3e56..29e69e1008509c0a31b4b070c18d4ec8393679ba 100644 (file)
@@ -1687,6 +1687,10 @@ static void read_process(struct lsfd_control *ctl, struct path_cxt *pc,
                        proc->kthread = !!(flags & PF_KTHREAD);
                free(pat);
        }
+       if (proc->kthread && !ctl->threads) {
+               free_proc(proc);
+               goto out;
+       }
 
        collect_execve_file(pc, proc, ctl->sockets_only);
 
@@ -1735,6 +1739,7 @@ static void read_process(struct lsfd_control *ctl, struct path_cxt *pc,
        else if (ctl->show_xmode)
                walk_threads(ctl, pc, pid, proc, parse_proc_syscall);
 
+ out:
        /* Let's be careful with number of open files */
         ul_path_close_dirfd(pc);
 }
index 0b093e96a79fd6603ec8a38aa02b726d2d74239e..2238ade1463c507c4c1ce51a6dee384a5133ea5f 100755 (executable)
@@ -31,7 +31,7 @@ ts_check_prog "ps"
 ts_cd "$TS_OUTDIR"
 
 {
-    "$TS_CMD_LSFD" -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \
+    "$TS_CMD_LSFD" --threads -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \
                   -Q '(PID < 3) and ((ASSOC == "cwd") or (ASSOC == "rtd"))'
     echo $?
 } > $TS_OUTPUT 2>&1