misterade
March 24th, 2012, 02:08 PM
First of all: hello to everybody ):P, I'm new to this forum but not to ubuntu. I used to post on the italian ubuntu forum and now I'm moving here :-).
I have a quite frustrating problem with the clone() system call in the C language.
I'm trying to use it with the flag CLONE_CHILD_CLEARTID but I cant see any change in the value of the field I specify as argument. Here it is a simple code:
int the_child(){
exit(0);
}
int main(int argc, char * argv[])
{
pid_t child_id = 99;
printf("child %p\n",child_id);
clone((int (*)(void *))the_child,
NULL,
CLONE_VM | CLONE_CHILD_CLEARTID | SIGCHLD,
NULL, NULL,NULL, child_id);
sleep(1);
printf("child %p\n",child_id);
}
However when the two printf display always 99, What am I doing wrong?
I have a quite frustrating problem with the clone() system call in the C language.
I'm trying to use it with the flag CLONE_CHILD_CLEARTID but I cant see any change in the value of the field I specify as argument. Here it is a simple code:
int the_child(){
exit(0);
}
int main(int argc, char * argv[])
{
pid_t child_id = 99;
printf("child %p\n",child_id);
clone((int (*)(void *))the_child,
NULL,
CLONE_VM | CLONE_CHILD_CLEARTID | SIGCHLD,
NULL, NULL,NULL, child_id);
sleep(1);
printf("child %p\n",child_id);
}
However when the two printf display always 99, What am I doing wrong?