In message <3C0340E8.5030609@bilten.metu.edu.tr>, Muzaffer Ozakca wrote: >I noticed that after forking a child, an open() returns 4 as the file >descriptor where I suppose it to be 3, because the parent does not open >any file/pipe or anything before fork. Am I missing sth here? It is not >mentioned anywhere that fork() opens anything. The fork()ed process inherits the open files. So it seems that the parent did open a file - this could be e.g. syslog() or similar C library calls, a DNS lookup etc. To actually check this use strace (or truss if on a Saolaris box). >What I found, as a workaround is close(3). But, I don't know this will >be the right thing to do. Depends on "who" opens the file. Basically it is the right thing to do in the child. Bernd -- Bernd Petrovitsch Email : bernd@gams.at g.a.m.s gmbh Fax : +43 1 205255-900 Prinz-Eugen-Straße 8 A-1040 Vienna/Austria/Europe LUGA : http://www.luga.at -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/