One File Two Writers

int x = 100;
int fd = open("log", O_WRONLY | O_CREAT | O_TRUNC, 0644);

if (fork() == 0) {
    x += 1;
    write(fd, "child\n", 6);
    _exit(0);
}
wait(NULL);
x += 10;
write(fd, "parent\n", 7);
printf("%d\n", x);

What is printed, and what does log contain afterwards?

A

Prints 101 then 110; the child inherits the printf call after the if

B

Prints 110; log holds child\nparent\n

C

Prints 110; log holds parent\n, because the parent's descriptor has its own offset still at 0

D

Prints 111; log holds child\nparent\n, because both branches ran in the same address space