Signal handler followed by default action

Signal handler followed by default action

Post by jeff lu » Wed, 21 Sep 1994 07:00:11



Can someone tell me how to catch a signal and at the end of the signal
handler to invoke the default action.

Thanks,
Jeff Lutz
US WEST Technologies

 
 
 

Signal handler followed by default action

Post by Steve Bil » Sat, 24 Sep 1994 06:55:14



>Can someone tell me how to catch a signal and at the end of the signal
>handler to invoke the default action.

The following should work.  The only shortcoming I can see is that
it won't produce a core dump when it's supposed to.

        void (*prev_act)(int);

        prev_act = signal(signal, handler);
          :

        void handler(int sig)
        {
                /* your stuff */

                switch (prev_act) {
                case SIG_DFL:
                        if ((signal >= SIGHUP && signal <= SIGUSR2)
                        || signal == SIGVTALRM || signal == SIGPROF
                        || signal == SIGLOST) {
                                exit(1);
                        }
                        break;
                case SIG_IGN:
                        break;
                default:
                        (*prev_act)(sig);
                        break;
        }

M, BATR..
..Steve Bilan

 
 
 

Signal handler followed by default action

Post by Mark Brop » Sat, 24 Sep 1994 16:47:01




>>Can someone tell me how to catch a signal and at the end of the signal
>>handler to invoke the default action.
>The following should work.  The only shortcoming I can see is that
>it won't produce a core dump when it's supposed to.
>    void (*prev_act)(int);
>    prev_act = signal(signal, handler);
>      :
>    void handler(int sig)
>    {
>            /* your stuff */
>            switch (prev_act) {
>            case SIG_DFL:
>                    if ((signal >= SIGHUP && signal <= SIGUSR2)
>                    || signal == SIGVTALRM || signal == SIGPROF
>                    || signal == SIGLOST) {
>                            exit(1);
>                    }
>                    break;
>            case SIG_IGN:
>                    break;
>            default:
>                    (*prev_act)(sig);
>                    break;
>    }

That's unnecessary. Just go:
void handler(int sig)
{
        /* your stuff */
        signal(signal,prev_act);
        raise(signal);
        signal(signal,handler);
Quote:}

A round about way of doing it yes, but it should work perfectly.

        Mark Brophy

 
 
 

1. Signal handlers inside signal handlers

Greetings Netters,

Unfortunately, the project I'm working on requires I mess with nested signal
handlers, and I've checked out obvious manuals and the POSIX std for clues,
but I'm having no luck.

What I'm trying to do is within a signal handler, plant another handler.
For example

#include        blah blah blah

foo2( int signo )
{
        printf("Caught the second sigalrm\n");

foo1( int signo )
{
        printf("Caught the first sigalrm\n");
        signal( SIGARLM, foo2 );
        alarm(1);

        for (;;)
                ;

main()
{
        signal( SIGALRM, foo1 );
        alarm(3);

        /* Wait for the first alarm */
        sleep(10);

The above program when run, prints the message from function foo1
but never reaches foo2.  Note that my project dictates that I can't
exit foo2, until foo1 has run.
I've tried messing with posix signals (sigaction etc), but have the
same problem.

Has anyone tried to do this sort of thing before??

Thanks in advance,
Scott Wallace

2. ISDN: ipppd dies without giving a hint why

3. Termination Signals and default action

4. Howto redirect stdout ...

5. trap "action; exit" signals = trap "action" exit?

6. ipfwadm ??

7. Threads performance - allow signal handler to not call handler

8. pop3 account

9. trap "<new trap action>; $(get_old_trap SIGNAL)" SIGNAL

10. Signal handlers are not reset after signal delivery

11. blocking signals in signal handler -- True or False quiz

12. Registering signal inside signal handler

13. Registering client data on signal manager side andreceiving it in signal handler