On Sat, July 18, 2020 18:52, Otto Moerbeek wrote:
>
> this is an old System V idiom. See e.g. 
> https://man7.org/linux/man-pages/man3/sigset.3.html
>
> -Otto
>
>
This compiled fine, but fine is it?

#include <signal.h>

static void increase_verbosity(int signum)
{
  verbosity++;
  cerr << "Increased verbosity to " << verbosity << endl;
}

static void decrease_verbosity(int signum)
{
  verbosity--;
  cerr << "Decreased verbosity to " << verbosity << endl;
}

struct sigaction inc_action {
        .sa_handler = increase_verbosity,
        .sa_flags = 0
};
struct sigaction dec_action {
        .sa_handler = decrease_verbosity,
        .sa_flags = 0
};


void install_verbosity_control_signal_handlers()
{
  sigaction(SIGUSR1, &inc_action, NULL);
  sigaction(SIGUSR2, &dec_action, NULL);
}


Reply via email to