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

int main(void) {
    pid_t pid = fork();

    if (pid < 0) {
        perror("fork");
        exit(1);
    }

    if (pid == 0) {
        printf("child pid=%d: before getchar\n", getpid());
        fflush(stdout);

        int c = getchar();

        printf("child pid=%d: got %d\n", getpid(), c);
        exit(0);
    } else {
        printf("parent pid=%d, child=%d\n", getpid(), pid);
        wait(NULL);
    }

    return 0;
}
