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 (at) cn.ibm.com>. */ 6 #define _GNU_SOURCE 7 #include <stdio.h> 8 #include <sys/types.h> 9 #include <stdlib.h> 10 #include <sched.h> 11 #include <unistd.h> 12 13 int child () 14 { 15 sleep(1); 16 return 0; 17 } 18 19 typedef int (* myfunc)(); 20 21 #define STACK_SIZE 1024 22 23 int main () 24 { 25 pid_t pid; 26 static __attribute__ ((aligned (16))) char stack[STACK_SIZE]; 27 28 #ifdef __ia64__ 29 pid = __clone2((myfunc)&child, stack, STACK_SIZE, CLONE_FS, NULL); 30 #else 31 pid = clone((myfunc)&child, stack + STACK_SIZE, CLONE_FS, NULL); 32 #endif 33 if (pid < 0) 34 { 35 perror("clone called failed"); 36 exit (1); 37 } 38 39 return 0; 40 } 41