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