trace-fork.c revision 98d884bfd78ea7a37f46515c6e9e3635a95d8cbc
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 10void 11child () 12{ 13 printf("Fork Child\n"); 14 sleep(1); 15} 16 17int 18main () 19{ 20 pid_t pid; 21 pid = fork (); 22 23 if (pid == -1) 24 printf("fork failed!\n"); 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