c - How to check if a file still exists using a file descriptor -


I have a file descriptor that is set to a positive value with the result of an open () function, Indicates a line When I delete the original file, then still there is a positive integer. I want to know that if I delete a file for some reason, then how will I know that this file descriptor is no longer valid. In short, how can I know if the file that is giving the FD signal is still there or not? I am trying to do this in free BSD in C.

Unix system delete files you open) Delete all references to file from file system but file descriptor < Em> still valid anybody reading and writing will succeed, because they will still be there with the file name.

In other words, you can not completely delete a file until the file descriptor is closed. Once closed, the file will be automatically removed.

With a valid file descriptor, you can check that the file name still exists, such as

  printf ("% d \ N", buf.st_nlink); // is not a filename   

where buf is a struct stat initialized with fstat .

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -