On Sun, 2005-12-25 at 16:28 +0200, George Zhim wrote: > > This is not true, actually. They do share the struct file and since that is > > where the current position lives, the current position WILL be affected. > > That's why if parent and child both have a log file open (from before fork) > > and write to it, output from BOTH will be there, mixed together. > > but if, after fork, one of them (either the child or the father) > closes the file, > how will it still stay available to the second one ? Reference counting. A sys_close() ends up executing the following (sys_close->filp_close->fput): if (atomic_dec_and_test(&file->f_count)) __fput(file); So the struct file is not discarded until the last reference is closed. -- fm -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/