Hi all.
I write this here to see if you can give me some clue on a strange behaviour
with the clone system call. Really I want a hint about if it is a kernel
issue, a glibc(pthreads) one or a gcc issue. If sometimes it works looks
like not a kernel issue, but who knows...
Abstract: compiling a program with 'gcc -pthread' or just linking with
-lpthread (even if I just do not call any pthread_xxx), makes the
'clone()' call (glibc) fail. It does not jump to the given function.
Checked on both:
gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.4mdk)
gcc version 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)
Sample test:
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#define STSZ (4*1024)
int pslave(void *data);
int main(int argc,char** argv)
{
int tid;
char* stack;
stack = (char*)valloc(STSZ);
puts("about to clone...");
tid = clone(pslave,stack+STSZ-1,CLONE_VM|SIGCHLD,0);
if (tid<0)
{
perror("clone");
exit(1);
}
puts("clone ok");
wait(0);
free(stack);
return 0;
}
int pslave(void *data)
{
puts("slave running");
sleep(1);
puts("slave done");
return 0;
}
-- J.A. Magallon \ Software is like sex: It's better when it's free mailto:jamagallon@able.es \ -- Linus Torvalds, FSF T-shirt Linux werewolf 2.4.19-pre10-jam3, Mandrake Linux 8.3 (Cooker) for i586 gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.4mdk) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:32 EST