My problem is that with
lsof -p pid
I can find out the list of opened file of a process whose process id is pid. But is there a way to find out the file offset of each accessed file ?
Please give me some suggestions ?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
On linux, you can find the position of the file descriptor number
N of process
$ cat /proc/687705/fdinfo/36 pos: 26088 flags: 0100001
The same file can be opened several times with different positions using several file descriptors, so you'll have to choose the relevant one in the case there are more than one. Use:
$ readlink /proc/$PID/fd/$N
to know what is the file to which the corresponding file descriptor is attached (it might not be a file, in this case the symlink is dangling).
lsof can do this, with the
Under Linux, it gets its information from
/proc, so you can get it there as well.