LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alex Davis <alex14641@yahoo.com>
To: linux-kernel@vger.kernel.org
Subject: signal handling issue.
Date: Tue, 18 May 2004 22:45:07 -0700 (PDT)	[thread overview]
Message-ID: <20040519054507.63816.qmail@web50201.mail.yahoo.com> (raw)

There appears to be a change between linux 2.4 and 2.6
in how signals are handled. As a test, I wrote the program
below:

#include <stdio.h>
#include <signal.h>
#include <setjmp.h>

static jmp_buf env;

static void handler(int s) {
        printf("caught signal %d\n", s);
        longjmp(env, 1);
}

int main() {
        int * p = 0;

        printf("write\n");
        signal(SIGSEGV, handler);
        if ( ! setjmp(env) )
        {
                *p = 0;
        }

        printf("read\n");
        signal(SIGSEGV, handler);
        if ( ! setjmp(env) )
        {
                int a = *p;
        }
        return 0;
}

When run on 2.4.26, the program prints:

write
caught signal 11
read
caught signal 11


Which (I think) is expected, but when run on 2.6.5,
the program prints:

write
caught signal 11
read
Segmentation fault

It's as if the second call to signal is being ignored.
Is this a bug or a feature?

-Alex



=====
I code, therefore I am


	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

             reply	other threads:[~2004-05-19  6:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-19  5:45 Alex Davis [this message]
2004-05-19  6:18 ` Ulrich Drepper
2004-05-19 11:39 ` Richard B. Johnson
2004-05-19  5:56 Alex Davis
2004-05-19  6:56 Alex Davis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040519054507.63816.qmail@web50201.mail.yahoo.com \
    --to=alex14641@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: signal handling issue.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).