Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Bad file descriptor when trying to close file handle

by ikegami (Patriarch)
on Mar 03, 2022 at 15:27 UTC ( [id://11141806]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Bad file descriptor when trying to close file handle
in thread Bad file descriptor when trying to close file handle

A bit more on this.

Files exists independently of directory entries in unix. Think of them as being referenced-counted. They exist as long as they are referenced by a directory entry or by a file handle.

This means you can have "anonymous files". perl -i uses this (which is why it doesn't work on Windows without an extension). File::Temp creates these by default.

ls -l even shows how many times a file is referenced by a directory entry (second column). For plain files, it's usually one. For directories, it should be more than one.

$ ls -ld . .. .bash* bin usr drwxr-xr-x 10 ikegami ikegami 4096 Feb 19 23:53 ./ drwxr-xr-x 3 root root 4096 Dec 10 21:14 ../ -rw------- 1 ikegami ikegami 163 Jan 3 02:07 .bash_logout -rw------- 1 ikegami ikegami 2318 Jan 3 02:07 .bashrc -rw------- 1 ikegami ikegami 0 Jan 3 02:07 .bashrc_extra drwx------ 2 ikegami ikegami 4096 Feb 14 12:13 bin/ drwx------ 3 ikegami ikegami 4096 Jan 24 15:39 usr/

See how .. is referenced by three directory entries? Those are /home, /home/. and /home/ikegami/..

See how . is referenced by ten directory entries? Those are /home/ikegami, /home/ikegami/., /home/ikegami/bin/.., /home/ikegami/usr/.., etc.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11141806]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-23 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found