Ssh – Why did sshd delete the /dev/zero

arch linuxdevicesfile-descriptorslinuxsshd

When I do lsof +c 0 | grep /dev/zero, I see the following two lines:

sshd    19064    root  DEL    REG    0,4    497862    /dev/zero
sshd    19064    root  DEL    REG    0,4    498725    /dev/zero

The DEL keyword is what intrigues me – from the manpages, it means:

DEL for a Linux map file that has been deleted

However, last time I checked my /dev/zero was still there, even if I reboot… So why would sshd attempt to delete this character device and why would it even succeed given that:

  • It is a character device, not a file
  • it is owned by root

OS info: Linux localhost 3.4.103 #1 SMP PREEMPT Thu Dec 18 13:07:12 CST 2014 armv7l GNU/Linux (Arch Linux)

Best Answer

DEL doesn't indicate that that process deleted /dev/zero, but that that process is using /dev/zero and the instance of /dev/zero that was being used has since been deleted. For example, if I have a command (say some-command) that uses /some/file and I do:

$ some-command &
$ rm /some/file
$ touch /some/file

Then lsof for /some/file would look like:

some-command    ...    ...  DEL    ...    ...    ...    /some/file

The contents of the deleted file continue to remain on disk until the process lets go or is killed, but won't be directly accessible.

The version of /some/file that I created using touch is not the one that some-command is using.