You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a file is deleted while still opened by a process, the fd under /proc/$pid/fd/$fd will show up as
[tatref@srv dev]$ ls -ld /proc/12779/fd/*lr-x------ 1 tatref tatref 64 Oct 16 01:00 /proc/12779/fd/4 -> '/home/tatref/dev/tes (deleted)'
We can get that info with
use std::fs::File;use std::fs::Metadata;use std::os::unix::fs::MetadataExt;let f = File::open(&format!("/proc/{}/fd/{}", p.pid, fd.fd)).unwrap();let metadata = f.metadata().unwrap();if metadata.nlink() == 0{}
So this means format a String, open a file, and do a syscall to get metadata.
Currently it seems there is no easier API in procfs to access this information (please correct me if I'm wrong). FDTarget has a Path variant, but there is no guarantee that another file with the same name hasn't be created.
Maybe we could store a File in the FDInfo, and add it where it is created:
Hi,
If a file is deleted while still opened by a process, the fd under
/proc/$pid/fd/$fd
will show up asWe can get that info with
So this means format a String, open a file, and do a syscall to get metadata.
Currently it seems there is no easier API in
procfs
to access this information (please correct me if I'm wrong).FDTarget
has aPath
variant, but there is no guarantee that another file with the same name hasn't be created.Maybe we could store a
File
in theFDInfo
, and add it where it is created:procfs/procfs/src/process/mod.rs
Lines 149 to 175 in e303757
What do you think?
The text was updated successfully, but these errors were encountered: