Started by Ricky NelsonAug 26, 2021

Open
What happens to an open file handle on Linux if the pointed file gets moved or deleted?

1 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 1 VIEWES SHARE

What happens to an open file handle on Linux if the pointed file meanwhile gets:

  • Moved away -> Does the file handle stay valid?
  • Deleted -> Does this lead to an EBADF, indicating an invalid file handle?
  • Replaced by a new file -> Does the file handle pointing to this new file?
  • Replaced by a hard link to a new file -> Does my file handle "follow" this link?
  • Replaced by a soft link to a new file -> Does my file handle hit this soft link file now?

Why I'm asking such questions: I'm using hot-plugged hardware (such as USB devices etc.). It can happen, that the device (and also its /dev/file) gets reattached by the user or another Gremlin.

What's the best practice dealing with this?

0 Replies

You must be Logged in to reply
Trending Categories
95
Software18
DevOps35
Frontend Development19
Backend Development17
Server Administration13
Linux Administration16
Data Center20
Sentry22
Terraform19
Ansible19
Docker19
Penetration Testing12
Kubernetes13
NGINX14
JenkinsX16
Jenkins20
SSL10
Ethical-Hacking10
Python12
NodeJs15
RedHat14
Github18
AngularJs15
Google Cloud Platform (GCP)6
SonarQube13
Amazon Web Service (AWS)13
VMware17
Blockchain12
Snipe-IT7