

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

int gv = 5;

int main() {
    int *hv = malloc(sizeof(int));
    *hv = 23;
    printf("before fork\n");
    pid_t p = fork();
    if (p == 0) {
        gv++;
        (*hv)++;
        printf("I'm childish. %d (%d, %d)\n", p, gv, *hv);
    } else {
        gv--;
        (*hv)--;
        //kill(p, SIGKILL);
        waitpid(p, NULL, 0);
        printf("I'm the parent here! %d (%d, %d)\n", p, gv, *hv);    
    }
    
}