fuser

Updated: April 19, 2023

List the process IDs of all processes that have one or more files open (POSIX)

Syntax:

fuser [-cfsu] file...

Runs on:

QNX Neutrino

Options:

-c
Treat the file as a filesystem mountpoint and report on any files open in the filesystem.
-f
Operate only on the named files (affects block-special).
-s
(QNX Neutrino extension) Operate silently; return the indication of open files in the exit status.
-u
Display the user name of each process.

Description:

The fuser utility writes to standard output the process IDs of processes running on the local system that have one or more named files open. For block special devices, all processes using any file on that device are listed.

This utility writes to standard error additional information about the named files indicating how the file is being used:

When standard output and standard error are directed to the same file, the output is interleaved so that the filename appears at the start of each line, followed by the process ID and characters indicating the use of the file. Then, if you specified the -u option, the user name or user ID for each process using that file is written.

A newline character is written to standard error after the last output described above for each file operand.

Examples:

Suppose that /q6 is mounted on /dev/hd0t178 and has a process with an open file /q6/Z:

This command: Gives this output: Because:
fuser /q6 /q6: Nothing has /q6 (a directory) directly open
fuser -c /q6 /q6: 811026o The file is inside the /q6 filesystem
fuser /dev/hd0t178 /dev/hd0t178: 811026o The file is inside the filesystem mounted on the (block) hd0t178
fuser -f /dev/hd0t178 /dev/hd0t178: The -f option indicates that you want to treat hd0t178 as the target file directly
fuser /q6/Z /q6/Z: 811026o You specified a file; in this case, it doesn't matter if you specify -c or -f

Exit status:

0
Success.
>0
An error occurred or some open files were found.