LKML Archive on
help / color / mirror / Atom feed
From: Alex Davis <>
Subject: signal handling issue.
Date: Tue, 18 May 2004 22:45:07 -0700 (PDT)	[thread overview]
Message-ID: <> (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

#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;

        signal(SIGSEGV, handler);
        if ( ! setjmp(env) )
                *p = 0;

        signal(SIGSEGV, handler);
        if ( ! setjmp(env) )
                int a = *p;
        return 0;

When run on 2.4.26, the program prints:

caught signal 11
caught signal 11

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

caught signal 11
Segmentation fault

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


I code, therefore I am

Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

             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:

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

  git send-email \ \ \ \
    --subject='Re: signal handling issue.' \

* 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).