Welcome to the Linux Foundation Forum!

Lab 21.1 - Can someone explain signals and signal handlers please?

I am a bit lost here. I think I understand the slides. But the program of the lab 21.1 is not easy to grasp. In particular I am not able to answer the questions properly. Can someone explain the answers please?

Do you know any good resource to understand signals and signal handlers better?

Comments

  • Elyas
    Elyas Posts: 28
    edited February 2016
    Sorry, that's not what I am looking for. I understand the concept. But I don't understand the implementation details.

    I think I start to understand the implementation of signals (see source code of said lab).
    I have one question though:

    What does it mean when a signal is blocked? Is it correct when I say a signal is not let through, i.e. blocked? If a signal is blocked then why is it handled?
    sigact.sa_mask = sigmask_new;	/* block signals in the handler itself  */
    
  • coop
    coop Posts: 915
    Please note we don't expect students to be C programmers, although it is nice if they are. The only reason the source code is included in the text (instead of just a downloadable file) is to avoid the problems some students have when downloading on windows machines; instead they can cut and paste.

    When a signal is blocked it is *temporarily* prevented from being handled; as soon as the blockage is removed the "handler" deals with it, doing whatever should be done, including possibly killing the program. Think of it as a "do not disturb" sign on the door; when the sign is removed the hotel room can be cleaned. The signal should never be "dropped"; it should be dealt with whenever the blockage is removed.

    This is a lab where we are trying to teach something, not just quiz the knowledge of what is in the section earlier.

Categories

Upcoming Training