blob: db1936dd71d55335219371abbffd2f8761e75d10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* Ltrace Test : trace-clone.c.
Objectives : Verify that ltrace can trace to child process after
clone called.
This file was written by Yao Qi <qiyao@cn.ibm.com>. */
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <sched.h>
int child ()
{
sleep(1);
return 0;
}
typedef int (* myfunc)();
#define STACK_SIZE 1024
int main ()
{
pid_t pid;
static char stack[STACK_SIZE];
#ifdef __ia64__
pid = __clone2((myfunc)&child, stack, STACK_SIZE, CLONE_FS, NULL);
#else
pid = clone((myfunc)&child, stack + STACK_SIZE, CLONE_FS, NULL);
#endif
if (pid < 0)
{
perror("clone called failed");
exit (1);
}
return 0;
}
|