Results 1 to 2 of 2
hiii
What happens when a process executes unlink(".");
What is the current directory of the process ? (Assume superuser permissions are given.)
Thanking you
Krish...
- 02-19-2010 #1Just Joined!
- Join Date
- Jan 2010
- Posts
- 2
What happens when a process executes unlink(".");
hiii
What happens when a process executes unlink(".");
What is the current directory of the process ? (Assume superuser permissions are given.)
Thanking you
Krish
- 02-19-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Superuser permissions are irrelevant. When a process does an unlink of any file and/or directory, it decrements the link count of the file/directory, and the OS will not actually delete the file/directory until its link count == 0. When you cd to a directory, or open a file, the link count is incremented by one. So, when you unlink '.' (assuming it is empty, otherwise unlink() would return an error), you are still in that directory, even though it will not be visible to a user (the directory entry is gone, but not the directory itself). So, you can move to another directory (including '..'), at which time the link count will be decremented, and if it is 0 then the OS will physically remove it.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
