jeudi 24 décembre 2015

Use sigaltstack to dynamically alter stack on which the signal handler runs

So I am trying to raise 100 signals (SIGUSR1) and have them all run in their own stack, can someone explain how I can go about doing this? Will the following code

std::signal(SIGUSR1, signal_andler);

for (int i = 0; i < 100; ++i) {
    stack_t stack;
    stack.ss_flags = 0;
    stack.ss_size = FIBER_STACK;
    stack.ss_sp = malloc( FIBER_STACK );

    sigaltstack( &stack, 0 );

    raise( SIGUSR1 );
}

I read other implementations using sigaction somewhere, but again I have no idea what that is. I apologize if I have completely misunderstood how sigaltstack is supposed to work.. Thank you for the help!

Aucun commentaire:

Enregistrer un commentaire