about summary refs log tree commit diff stats
path: root/tests32/test09.c
blob: e4a560505d1bf89a1d78d1ebd738f56801e0ab33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h> 
#include <sys/types.h> 
#include <unistd.h> 
  
void forkexample() 
{ 
    int x = 1; 
  
    if (fork() == 0) 
        printf("Child has x = %d\n", ++x); 
    else {
        usleep(20000);
        printf("Parent has x = %d\n", --x); 
    }
} 
int main() 
{ 
    forkexample(); 
    return 0; 
}