#include<stdio.h>
#include<unistd.h>
main( )
{
int signal;
int pid;
printf ( "\n hi i am parent process i am going to create a child\n " ) ; pid= fork( ) ;
if ( pid== 0 )
{
printf ( "\n hi i am child process. i am going to jump to a different parent process\n " ) ; execl( "/bin/ls" , "ls" , "-l" , NULL) ;
}
else if ( pid> 0 )
{
printf ( "\n hi i am parent. i will wait for my child to complete\n " ) ; wait( & signal) ;
printf ( "\n i got signal=%d so my child jumped to another process. i am exiting\n " , signal
) ; }
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8dW5pc3RkLmg+Cm1haW4oKQp7CglpbnQgc2lnbmFsOwoJaW50IHBpZDsKCXByaW50ZigiXG5oaSBpIGFtIHBhcmVudCBwcm9jZXNzIGkgYW0gZ29pbmcgdG8gY3JlYXRlIGEgY2hpbGRcbiIpOwoJcGlkPWZvcmsoKTsKCWlmKHBpZD09MCkKCXsKCQlwcmludGYoIlxuaGkgaSBhbSBjaGlsZCBwcm9jZXNzLiBpIGFtIGdvaW5nIHRvIGp1bXAgdG8gYSBkaWZmZXJlbnQgcGFyZW50IHByb2Nlc3NcbiIpOwoJCWV4ZWNsKCIvYmluL2xzIiwibHMiLCItbCIsTlVMTCk7Cgl9CgllbHNlIGlmKHBpZD4wKQoJewoJCXByaW50ZigiXG5oaSBpIGFtIHBhcmVudC4gaSB3aWxsIHdhaXQgZm9yIG15IGNoaWxkIHRvIGNvbXBsZXRlXG4iKTsKCQl3YWl0KCZzaWduYWwpOwoJCXByaW50ZigiXG5pIGdvdCBzaWduYWw9JWQgc28gbXkgY2hpbGQganVtcGVkIHRvIGFub3RoZXIgcHJvY2Vzcy4gaSBhbSBleGl0aW5nXG4iLHNpZ25hbCk7Cgl9Cn0=