0

Im struggling to figure this out. Under which circumstances does the following program produce a different number of lines than three?

#include <unistd.h>
#include <stdio.h>

int main() {
  printf("I am the parent!\n");
  if (fork() == 0) {
    printf("I am the child!\n");
  } else {
    printf("I am still parent!\n");
  }
}

My first impulse is is to say that it will only produce two lines of output when fork() fails. But can it also produce a different amount of output lines?

0 Answers0