mirror of
https://github.com/ptitSeb/box64.git
synced 2024-11-23 06:30:22 +00:00
20 lines
316 B
C
20 lines
316 B
C
|
#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;
|
||
|
}
|