Question 2 (11 points, 20 minutes)

Part 1 (8 points)

What is the output of this program if standard output is going to the screen?
#include < setjmp.h >
#include < stdio.h >

main()
{
  jmp_buf jb1;
  int i, j, dummy;

  j = 0;

  i = setjmp(jb1);
  printf("i = %d.  j = %d\n", i, j);

  printf("Calling fork()\n");
  if (fork() == 0) {
    j++;
    printf("i = %d.  j = %d\n", i, j);
  } else {
    wait(&dummy);
  }

  if ((i + j) % 2 == 0 || i + j > 4) {
    printf("%d %d Exiting\n", i, j);
  } else {
    longjmp(jb1, i+1);
  }
}

Part 2 (3 points)

Would your answer be different if standard output were redirected to a file? Why?