trace-clone.c revision aee093126654f722523b47848a0c5449e39cf4bb
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 sleep(1); 15 return 0; 16} 17 18typedef int (* myfunc)(); 19 20#define STACK_SIZE 1024 21 22int main () 23{ 24 pid_t pid; 25 static char stack[STACK_SIZE]; 26#ifdef __ia64__ 27 pid = __clone2((myfunc)&child, stack, STACK_SIZE, CLONE_FS, NULL); 28#else 29 pid = clone((myfunc)&child, stack,CLONE_FS, NULL ); 30#endif 31 if (pid < 0) 32 { 33 perror("clone called failed"); 34 exit (1); 35 } 36 37 return 0; 38} 39