logo

Crowdly

Dado el siguiente código C, ¿qué sucede cuando el proceso recibe la señal  SIGIN...

✅ 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, ¿qué sucede cuando el proceso recibe la señal SIGINT?

#include <fcntl.h>

#include <semaphore.h>

#include <signal.h>

#include <stdio.h>

#include <stdlib.h>

#include <sys/stat.h>

#include <sys/wait.h>

#include <unistd.h>

#define SEM_NAME "/example_sem"

int main(void) {

sem_t *sem = NULL;

struct sigaction act;

if ((sem = sem_open(SEM_NAME, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 0)) ==

SEM_FAILED) {

perror("sem_open");

exit(EXIT_FAILURE);

}

sigemptyset(&(act.sa_mask));

act.sa_flags = 0;

/* The handler for SIGINT is set. */

act.sa_handler = SIG_IGN;

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

perror("sigaction");

exit(EXIT_FAILURE);

}

printf("Starting wait (PID=%d)\n", getpid());

sem_wait(sem);

printf("Finishing wait\n");

sem_unlink(SEM_NAME);

}

0%
0%
100%
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!