When working with remote filesystems such as sshfs or smbfs, it is command that they become stale due to network problems. To check if the mount is stale or not, I usually use the command ls to see if I can list the contents of the remote mounts. When these remote mounts are stale, the ls command just waits for a long time until outputting, after some minutes, something along the lines of:

ls: cannot access '/mnt/remote': Input/output error

Instead of waiting for this error, is there a way to stop the ls command from within the same bash session? The regular Control+C does not seem to do the job. Closing the bash shell works, but this is undesirable. Any alternatives?


No, since ls (or any other file-operating process) is in the process state "uninterruptible sleep", there is nothing that can interrupt it, even SIGKILL can't.

Maybe you can lower the timeout values when mounting remote filesystems. sshfs has ServerAliveInterval and ServerAliveCountMax.

  • 1
    Filesystem operations are seen as "short waits" and are not interruptable. If your OS supports a forced unmount, you may do this and then kill the ls as it then no longer waits to an existing filesystem. – schily Apr 12 '16 at 10:00
  • @schily That would make a good answer. It fixed my issue. – forgivenson Apr 1 '19 at 16:41

To stop all ls processes:

pkill --signal SIGKILL ls
  • Is there a way, however, to stop the "ls" process within the same bash session? i.e.: without opening a new bash shell – UndeadKernel Apr 12 '16 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.