The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 09-29-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
When a program is loaded by the OS,
it is automatically given 3 open files...

stdin -> fd=0
stdout -> fd=1
stderr -> fd=2

By closing all fd's you guarantee that
the next file you open...

open(...)

...will be assigned fd 0