logo

Crowdly

Dado el siguiente código C, ¿cuándo se imprimirá el mensaje  "Signal number 2 re...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Dado el siguiente código C, ¿cuándo se imprimirá el mensaje "Signal number 2 received"?

#include <signal.h>

#include <stdio.h>

#include <stdlib.h>

#include <sys/types.h>

#include <unistd.h>

/* Handler function for the signal SIGINT. */

void handler(int sig) {

printf("Signal number %d received\n", sig);

fflush(stdout);

}

int main(void) {

struct sigaction act;

act.sa_handler = handler;

sigemptyset(&(act.sa_mask));

act.sa_flags = 0;

if (sigaction(SIGINT, &act, NULL) < 0) {

perror("sigaction");

exit(EXIT_FAILURE);

}

while (1) {

printf("Waiting Ctrl+C (PID = %d)\n", getpid());

sleep(9999);

}

}

100%
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.uam.es?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!