On Thu, Apr 27, 2006 at 04:54:09AM +0200, Michael Kerrisk wrote: > Justin, > > > Tags: upstream > > Any time you open a report like this you better make sure > that whatever you say holds against the latest upstream release. Do you mean of manpages?
> > It seems that the clone manpage is out of sync with the libc/kernel > > reality. > > > > In particular, the following succeeds, > > The preceding is nearly meaningless, because so vague. Succeeds > where? I write a program that called clone() and it didn't return -1 when the manpage suggested that it should have. If glibc passed it on to the kernel (which it apparently did, since it succeeded), then the kernel didn't return -1; otherwise glibc did. > What kernel? Linux andromeda 2.6.15-1-686 #2 Mon Mar 6 15:27:08 UTC 2006 i686 GNU/Linux > > but the annotation says that it > > should not: > > > > CLONE_NEWNS|CLONE_FS This still seems to succeed when I do a syscall (without libc). > > CLONE_THREAD (because CLONE_SIGHAND is not set) > > CLONE_SIGHAND (because CLONE_VM is not set) But these now return -1 (when using the "syscall" mechanism; see below). > And how did you test or verify this? If it was with a program, > show me the complete clone() call. Originally, I was doing it the "libc" way: #include <sched.h> // #include <syscall.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> int f(void *v) { assert(v==NULL); fprintf(stderr, "%s\n", __PRETTY_FUNCTION__); return 0; } int main() { char buf[1<<10]; const int flags=CLONE_NEWNS|CLONE_FS; fprintf(stderr, "%s\n", __PRETTY_FUNCTION__); if (-1==clone(f, buf, flags, NULL)) { perror("clone"); } exit(EXIT_SUCCESS); } But I finally got the "syscall" way to work, with the above updated results: #include <syscall.h> #include <asm/ldt.h> // bits/sched.h or linux/sched.h #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> int f(void *v) { assert(v==NULL); fprintf(stderr, "%s\n", __PRETTY_FUNCTION__); return 0; } _syscall5(int, clone, int, flags, void *, child_stack, int *, parent_tidptr, struct user_desc *, newtls, int *, child_tidptr); int main() { const int flags=0x0001ffff|0x00000200; /* CLONE_NEWNS|CLONE_FS; */ // 0x00000800; /* CLONE_SIGHAND */ // 0x00010000; /* CLONE_THREAD */ if (-1==clone(flags,0,0,0,0)) { perror("clone"); } fprintf(stderr, "%s\n", __PRETTY_FUNCTION__); exit(EXIT_SUCCESS); } > > There is also mention of a "CLONE_DETACHED" flag which is not > > otherwise mentioned; (the header files indicate that it is ignored). > > Mention where? Please be precise. I'm terribly sorry but, although I had updated to manpages 2.25-3, the manpage was already opened with 2.22 or so; CLONE_DETACHED is no longer mentioned. > > Also, I can't follow the description of sys_clone, mostly because the > > prototype doesn't make sense. Instead of being a prototype of clone, > > it looks like it is just copied from the definition (somewhere). > > Doesn't it make more sense to include something like: > > > > clone(int flags, void *child_stack, int *parent_tidptr, > > struct user_desc *newtls, int *child_tidptr); > > No, because it is not prototyped in header files. > Thus either _syscall5() or syscall() is required. Okay. > > Instead of the stuff that some scary-looking macro in a burried header > > file that generates the definition? :) > > The people who find it scary probably don't need clone(). > > Justin -- vague bug reports like this waste my time. Not my intent, of course. > (I may be wrong, but this bug report sounds "speculative" -- that > is, you don't really have much experience with clone().) This is true, I do not. Justin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]