mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-08-19 01:22:36 +08:00
27 lines
415 B
C
27 lines
415 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int data = 10;
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int pid;
|
|
|
|
pid = fork();
|
|
if (pid == 0) {
|
|
printf("Child process %d, data %d\n", getpid(), data);
|
|
data = 20;
|
|
printf("Child process %d, data %d\n", getpid(), data);
|
|
} else {
|
|
sleep(1);
|
|
printf("Parent process %d, data %d\n", getpid(), data);
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|