]>
git.proxmox.com Git - qemu.git/blob - tests/testclone.c
10 int thread1_func(void *arg
)
16 snprintf(buf
, sizeof(buf
), "thread1: %d %s\n", i
, (char *)arg
);
17 write(1, buf
, strlen(buf
));
23 int thread2_func(void *arg
)
28 snprintf(buf
, sizeof(buf
), "thread2: %d %s\n", i
, (char *)arg
);
29 write(1, buf
, strlen(buf
));
35 #define STACK_SIZE 16384
39 uint8_t *stack1
, *stack2
;
40 int pid1
, pid2
, status1
, status2
;
42 stack1
= malloc(STACK_SIZE
);
43 pid1
= clone(thread1_func
, stack1
+ STACK_SIZE
,
44 CLONE_VM
| CLONE_FS
| CLONE_FILES
| SIGCHLD
, "hello1");
46 stack2
= malloc(STACK_SIZE
);
47 pid2
= clone(thread2_func
, stack2
+ STACK_SIZE
,
48 CLONE_VM
| CLONE_FS
| CLONE_FILES
| SIGCHLD
, "hello2");
50 while (waitpid(pid1
, &status1
, 0) != pid1
);
51 while (waitpid(pid2
, &status2
, 0) != pid2
);
52 printf("status1=0x%x\n", status1
);
53 printf("status2=0x%x\n", status2
);
54 printf("End of clone test.\n");
57 int main(int argc
, char **argv
)