#include #include #include #include int main(){ pid_t pid = fork(); printf("pid = %u\n", pid); /* if pid is 0, we're in the child process. If it's not 0, we're in the parent */ if(pid){ /* Not 0 is true, so any valid PID is true */ sleep(1); return 0; } while(1) { sleep(10); int fd = open("favorite_file", O_WRONLY | O_CREAT | O_TRUNC, 0644); const char *contents = "This is my favorite file"; write(fd, contents, strlen(contents)); close(fd); } return 0; }