Quiz 6

Problem 1 (2 pt)

Consider the following program. User will send a SIGINT signal to the program. In which condition the program may sleep forever?

int sig_int_flag;
main() {
  int sig_int();
  signal(SIGINT, sig_int);
  while (sig_int_flag == 0)
    pause();
}

sig_int() {
  signal(SIGINT, sig_int);
  sig_int_flag = 1;
}

Answer 1

answer1

Problem 2 (3 pt)

We can use kill(pid_t pid, int signo) to send signal to other processes. Which processes will receive the signal when the pid…

  1. pid > 0
  2. pid == 0
  3. pid < 0

Answer 2

answer2