To find all the file descriptors used by a process in Linux, you can use the "lsof" command.
The "lsof" command lists the open files for a process, including file descriptors. To list the file descriptors for a specific process, you can use the "-p" option followed by the process ID.
For example, to list the file descriptors for a process with a process ID of 12345, you can use the following command:
lsof -p 12345Source:www.lautturi.com
This will display a list of all the open files for the process, including the file descriptor, file type, and file name.
For example, the output might look like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME process 12345 john cwd DIR 8,1 4096 1234 /home/john/process process 12345 john rtd DIR 8,1 4096 212345 / process 12345 john txt REG 8,1 231456 123456 /usr/bin/process process 12345 john mem REG 8,1 16384 123457 /lib/libc-2.27.so process 12345 john mem REG 8,1 131072 123458 /lib/ld-2.27.so
This shows the file descriptor, file type, and file name for each open file for the process with a process ID of 12345.
You can also use the "-a" option to display all open files, regardless of the process. For example:
lsof -a
This will display a list of all open files on the system, including the process ID, file descriptor, file type, and file name.
Note: The "lsof" command must be run with root privileges to list the file descriptors for all processes.