Загрузка данных


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

int main() {
    int counter = 10;
    pid_t pid = fork();

    if (pid == 0) {
        counter = counter + 5;
        printf("Child: counter = %d, PID = %d, PPID = %d\n", counter, getpid(), getppid());
        exit(0);
    } else if (pid > 0) {
        counter = counter - 5;
        printf("Parent: counter = %d, PID = %d, Child PID = %d\n", counter, getpid(), pid);
    } else {
        perror("fork");
        exit(1);
    }
    return 0;
}