Messages in this thread | | | From | (Linus Torvalds) | Subject | Re: chdir for cloned tasks? | Date | 11 Aug 1997 17:16:47 GMT |
| |
In article <199708110603.IAA00596@mira.isdn.cs.tu-berlin.de>, Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> wrote: >> I understand what the CLONE_FS flag does -- my question was whether such >> a cloned task, when it makes a system call to sys_chdir, should get a >> private copy. The present sys_chdir code doesn't check whether the task >> is a clone or not, so one clone changing directory would change it for >> all clones. > >As Ingo said: This depends on whether CLONE_FS was there at clone(2) time. >If it was, changing the directory would change it for all clones. If it >wasn't, changing it does *not* change it for the other clones, because >they have a copy of proc->fs. > >So is this the intended behaviour? The application program can choose >whether it wants to share the cwd with the new clone. This moves policy >out of the kernel, so it seems like a good idea. The application program >cannot make this choice for the cwd individually; it would share the umask >and the root directory as well. This is probably acceptable.
It is indeed the intended behaviour. The whole point is that you can do an external "chroot" or "cd" command.
>AFAIK, being able to share the cwd between clones is required to implement >Posix threads (please somebody correct me if I'm wrong). So it would be >*wrong* if sys_chdir took clones into account.
I don't think POSIX actually specifies whether you share the cwd/root or not, but the point is that we have the choice (and as you say, the choice is in user space, not in kernel space).
Linus
| |