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?
Sign in to answer questions and track your progress
Sign In