Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/types.h>
- int main(int argc, char* argv[]){
- int p = 0;
- int status=0;
- int x = 1;
- p = fork();
- if ( p != 0 ) {
- wait(&status);
- printf(" x: %d\n", x);
- p = fork();
- if ( p==0 ){
- x--;
- printf(" x: %d\n", x);
- execl( "/bin/ls" , "ls", NULL );
- }
- } else {
- x = 3;
- printf(" x: %d\n", x);
- exit( 0 );
- }
- wait(&status);
- printf(" x: %d\n", x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement