Hi, All
I use clone() to create thread in LINUX. the call of clone is as
follows:
for(i = 0; i < n; i++) {
if((stack[i] = (char*)malloc(CHILD_STACK * sizeof(char)))
== NULL) {
fprintf(stderr, "<main>malloc stack error.");
exit(-1);
}
parm[i] = i;
if((pid[i] = clone(child_send_process, stack[i] +
CHILD_STACK, CLONE_VM|CLONE_FILES, &parm[i])) < 0) {
fprintf(stderr, "<main>clone send_child_process
error.");
exit(-1);
}
}
so n threads are created. But some of the thread will encounter
segmentation fault after runing some time. I am sure the pointer
allocated by my code is released correctly and the stack size here is
3M bytes.
Can anybody tell me some possibilities which will case segfault in
thread made by clone()??
Thanks.
----Kent