Why is 'df' hanging?

I used sshfs to mount a directory from some ssh server, and my network connection was lost. It appears df was trying to list that mount and instead of failing gracefully, it just got stuck :(


The most common cause of software like df hanging is when they're trying to read from a disk that isn't responsing properly.

Check the output from dmesg to see if this is the case -- a flaky drive will toss out a great deal of errors.

Unfortunately, this tends to be a hardware problem and you may be looking at having to replace the entire drive. I recommend you make backups of everything you can.


Not the case here, but for the record, note that some versions of the GNU implementation of df (since version 7.3, fixed in 8.29 (with this commit)) hang on readable fifo/named pipe files that have no writer, as they try to open them, as seen in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29038

$ mkfifo fifo
$ strace df fifo
[...]
open("fifo", O_RDONLY|O_NOCTTY  # hanging there