Checking currently open files on my
/Volumes/UNTITLED gives me 2 entries:
$ sudo lsof /Volumes/UNTITLED/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mds 62 root 8r DIR 1,6 32768 2 /Volumes/UNTITLED mds 62 root 19r DIR 1,6 32768 2 /Volumes/UNTITLED $
When I run
diskutil unmountDisk disk2, all descriptors are successfully closed (e.g. I cannot do
lsof /Volumes/UNTITLED/ anymore, since the folder is gone).
diskutil unmountDisk does to close file descriptors? Can I close file descriptors myself?
As far as I understand
diskutil is closed source. Can the question be answered by taking
Basically I'm trying to understand how to tell a process close a given file descriptor, e.g. emulate what unmount does.
I think telling the process to close a file descriptor should be illegal, as generally it can easily cause process to crash. However I think
diskutil unmountDisk somehow manages to gently asks
mds to no longer possess the file.
I'm curious if I can ask gently too. I know there's a
endfsent OS function, but it's not a program, I cannot run it to manipulate file descriptors open by different processes.