[Bug 232702] fuser does not list id of processes that have a file

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 25 May 2022 09:22:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232702

--- Comment #2 from Ali Abdallah <ali.abdallah@suse.com> ---
Created attachment 234203
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=234203&action=edit
Fix looping over active processes

I haven't tested fuser since long time. I'm running 13.1 now on multiple
machines, fuser sometimes gets active processes opening a specific file, and
sometimes not! 

It seemed random for me, but after having a closer look at the code, I think
the following loop is wrong:

while(cnt--)
    if (p->ki_stat != SZOMB)
        dofiles(procstat, p++, reqfiles, nfiles);

The above might skip active process entries, and IMHO it should be as follows

while(cnt--) {
    if (p->ki_stat != SZOMB) {
        dofiles(procstat, p, reqfiles, nfiles);
    }
    p++;
}

Attached a tiny patch that fixes the issue for me.

-- 
You are receiving this mail because:
You are the assignee for the bug.