Re: Re: file offset pointer accross fork() ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello...

> I can't really agree with you.
> lemme quote:
>
> asmlinkage int sys_fork(struct pt_regs regs)
> {
>          return do_fork(SIGCHLD, regs.esp, &regs, 0, NULL, NULL);
> }
>
> fork uses SIGCHLD. only.

Pfff, you are correct....so sorry for the wrong information. OK, I have 
done better research on 2.4.20 codes ( I assume it is still valid for 
2.6.x/2.6.x.x), when doing fork(), somewhere on the call chain you will 
call copy_files() (located on kernel/fork.c). Please study the function 
for complete informations.

>From what I see at a glance, since sys_fork() doesn't use CLONE_FILES, 
it will copy the latest information about all open files currently 
accessed by the parent. In the other hand, when calling clone with 
CLONE_FILES, it is simply incrementing the counter:

if (clone_flags & CLONE_FILES) {
                atomic_inc(&oldf->count);
                goto out;
        }

So, in short, fork() copy files_struct information, while 
clone(CLONE_FILES) simply take a note that more process share the 
structure.

> threads use CLONE_FS (which has nothing to do with open files.
> it is the file system struct which is current working directory, etc)
> and CLONE_FILES (which is open files).

yes, you are correct about it. Pardon me on my lack of knowledge in 
filesystem area...There is also an option for sharing namespace...but 
that is another story ;)

regards

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux