1 /* Ltrace Test : trace-fork.c 2 Objectives : Verify that ltrace can trace to child process after 3 fork 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 10 void child()11child () 12 { 13 printf("Fork Child\n"); 14 sleep(1); 15 } 16 17 int main()18main () 19 { 20 pid_t pid; 21 pid = fork (); 22 23 if (pid == -1) 24 puts("fork failed!"); 25 else if (pid == 0) 26 child(); 27 else 28 { 29 printf("My child pid is %d\n",pid); 30 wait(); 31 } 32 return 0; 33 } 34