ex:
复制内容到剪贴板
代码:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sched.h>
int variable;
int do_something(void*) {
variable = 42;
_exit(0);
}
int main(int argc, char *argv[]) {
void *child_stack;
char tempch;
variable = 9;
child_stack = (void *) malloc(16384);
printf("The variable was %d\n", variable);
clone(do_something, child_stack, CLONE_VM|CLONE_FILES, NULL);
sleep(1);
printf("The variable is now %d\n", variable);
return 0;
}taoewang@baryon:/home/taoewang/temp> ./a.out
The variable was 9
The variable is now 42
[
本帖最后由 wangzhonnew 于 2008-4-8 02:24 编辑 ]