Re: file offset pointer accross fork() ?

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

 



On 9/30/05, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
> Hello....
>
> > hmm...
> > what's the user-perspective difference between forking and threading,
> > regarding open files, then ?
>
> IIRC nothing. The reason is, both normal fork() and thread creation,
> which essentially calls clone(), use CLONE_FS that duplicate pointer of
> file_struct. So, unless you directly call clone() without CLONE_FS, you
> will get same result regarding open files structures

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.

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).

so does fork really share the same file offset ?
what's the difference between forking and threading regarding open files ?

Thanks !!

>
> Hope it helps
>
> 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