LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-13-2011, 03:13 AM   #1
rainman1985_2010
Member
 
Registered: Oct 2010
Posts: 34

Rep: Reputation: 0
What does closing an file descriptor mean?


As we know, every process has a table with a file descriptor table, in which each entry contains a file pointer pointing to the corresponding file table which contains a v-node pointer pointing to the v-node table.

When closing a file descriptor, are all these data structure deleted?
 
Old 03-13-2011, 10:31 AM   #2
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 217

Rep: Reputation: 21
Once the kernel has opened a file by name it stores that "file connection" under that descriptor number for faster access.
The structure is like that of system descritors, so the name.
An app. has no access to its file descriptor table only the kernel has.
Closing a file descriptor means the kernel writes all buffered data to the coresponding file.
A nother process can then read the actual data out of this file by sure (all is saved).
A file descriptor keeps alive until the app exits, even if the file is closed.
Closing a file means closing or deleting a file descriptor, what is not really done.
 
Old 03-13-2011, 12:56 PM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 65
Also keep in mind file descriptors are a finite resource. Long running programs that burn thought them and never close them can cause system problems because nothing will be able to open up files (or sockets).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Too many file open - How can we define Max limit of file descriptor janeshb Linux - Server 11 09-29-2009 10:41 AM
open local file error when creating file descriptor hellgirl Linux - Newbie 1 09-14-2009 10:03 PM
Deleted log file - how to get back via file descriptor and keep alive? prollocks Linux - General 1 05-29-2009 09:08 AM
Closing file descriptor for sshd that spawns remote threads Brad.Scalio@noaa.gov Linux - Software 3 06-02-2008 12:56 PM
apt-file returns nothing; 'bad file descriptor' overbored Debian 3 10-03-2004 09:13 PM


All times are GMT -5. The time now is 05:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration