Signalhandler and "-ansi -pedantic -Wall"

Discussion in 'C Programming' started by Simon Klein, May 31, 2007.

  1. Simon Klein

    Simon Klein Guest

    Hi,

    I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"
    catches the first signal but ignores the others. The installed handler
    seems to be gone after the first run.
    If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    But why?

    thx a lot for your answers in advance !
    Simon Klein, May 31, 2007
    #1
    1. Advertising

  2. Simon Klein

    Simon Klein Guest

    Al Balmer wrote:

    > On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:
    >
    >>Hi,
    >>
    >>I've got a problem. I wrote a Program with a Signalhandler Routine. If i
    >>use the compile flags "-ansi -pedantic -Wall", "(void)
    >>signal(SIGCHLD,Handler)" catches the first signal but ignores the others.
    >>The installed handler seems to be gone after the first run.
    >>If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    >>But why?
    >>
    >>thx a lot for your answers in advance !

    >
    > Off topic here. You should ask in a forum for the platform you're
    > working on, comp.unix.programmer, at a guess. As another guess, you
    > should probably be re-issuing the signal() in the handler. OTOH, you
    > probably should really be using sigaction() <g>. Go ask the experts in
    > comp.unix.programmer.
    >

    thx and sorry for the offtopic post
    Simon Klein, May 31, 2007
    #2
    1. Advertising

  3. Simon Klein

    Al Balmer Guest

    On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:

    >Hi,
    >
    >I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    >the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"
    >catches the first signal but ignores the others. The installed handler
    >seems to be gone after the first run.
    >If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    >But why?
    >
    >thx a lot for your answers in advance !


    Off topic here. You should ask in a forum for the platform you're
    working on, comp.unix.programmer, at a guess. As another guess, you
    should probably be re-issuing the signal() in the handler. OTOH, you
    probably should really be using sigaction() <g>. Go ask the experts in
    comp.unix.programmer.

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, May 31, 2007
    #3
  4. In article <465f399c$0$25625$>,
    Simon Klein <> wrote:

    >I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    >the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"


    Compile flags are not specified by the C standard, so to find out
    more about which compile flags you should use and what their effects
    are, you should consult with a newsgroup that deals with your toolchain.
    It appears that you are using gcc, so one of the gnu.* newsgroups
    would seem most appropriate.


    >catches the first signal but ignores the others. The installed handler
    >seems to be gone after the first run.
    >If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    >But why?


    <OT>

    I dunno. But signal semantics have changed over the years. One
    of the older common signal() semantics is that signals do not
    automatically rearm; if you are using such a system, then you
    have to reissue the signal() before leaving the signal handler.

    As to why it happens with those flags but not without them --
    well, possibly not having to rearm is an extension and -ansi
    is requesting that extensions not be used. Or there might be
    some other reason for it; ask in an appropriate newsgroup.
    --
    All is vanity. -- Ecclesiastes
    Walter Roberson, May 31, 2007
    #4
  5. On May 31, 5:26 pm, Al Balmer <> wrote:
    > On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:
    > >Hi,

    >
    > >I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    > >the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"
    > >catches the first signal but ignores the others. The installed handler
    > >seems to be gone after the first run.
    > >If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    > >But why?

    >
    > >thx a lot for your answers in advance !

    >
    > Off topic here. You should ask in a forum for the platform you're
    > working on, comp.unix.programmer, at a guess. As another guess, you
    > should probably be re-issuing the signal() in the handler. OTOH, you
    > probably should really be using sigaction() <g>. Go ask the experts in
    > comp.unix.programmer.


    signal() is ansi C, isn't it?

    By the way, the manpage seems to indicate that if you compile with
    different defines, different semantics are used. I suppose removing
    the -ansi changes the defines and allows the use of another semantic
    than the one of ansi C.
    Quentin Godfroy, May 31, 2007
    #5
  6. In article <>,
    Quentin Godfroy <> wrote:
    >On May 31, 5:26 pm, Al Balmer <> wrote:
    >> On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:


    >> >I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    >> >the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"


    >signal() is ansi C, isn't it?


    SIGCHLD is not.
    --
    "It is important to remember that when it comes to law, computers
    never make copies, only human beings make copies. Computers are given
    commands, not permission. Only people can be given permission."
    -- Brad Templeton
    Walter Roberson, May 31, 2007
    #6
  7. On May 31, 5:39 pm, -cnrc.gc.ca (Walter Roberson)
    wrote:
    > >On May 31, 5:26 pm, Al Balmer <> wrote:
    > >> On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:
    > >> >I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    > >> >the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"

    > >signal() is ansi C, isn't it?

    >
    > SIGCHLD is not.


    Whoops. Sorry for the mess.
    Quentin Godfroy, May 31, 2007
    #7
  8. Simon Klein

    Al Balmer Guest

    On 31 May 2007 14:36:39 -0700, Quentin Godfroy
    <> wrote:

    >On May 31, 5:26 pm, Al Balmer <> wrote:
    >> On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:
    >> >Hi,

    >>
    >> >I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    >> >the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"
    >> >catches the first signal but ignores the others. The installed handler
    >> >seems to be gone after the first run.
    >> >If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    >> >But why?

    >>
    >> >thx a lot for your answers in advance !

    >>
    >> Off topic here. You should ask in a forum for the platform you're
    >> working on, comp.unix.programmer, at a guess. As another guess, you
    >> should probably be re-issuing the signal() in the handler. OTOH, you
    >> probably should really be using sigaction() <g>. Go ask the experts in
    >> comp.unix.programmer.

    >
    >signal() is ansi C, isn't it?


    Yes, but the re-arming behavior is implementation defined. I don't
    know whether POSIX defines it.
    >
    >By the way, the manpage seems to indicate that if you compile with
    >different defines, different semantics are used. I suppose removing
    >the -ansi changes the defines and allows the use of another semantic
    >than the one of ansi C.


    --
    Al Balmer
    Sun City, AZ
    Al Balmer, May 31, 2007
    #8
  9. Al Balmer <> writes:
    > On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <> wrote:
    >>I've got a problem. I wrote a Program with a Signalhandler Routine. If i use
    >>the compile flags "-ansi -pedantic -Wall", "(void) signal(SIGCHLD,Handler)"
    >>catches the first signal but ignores the others. The installed handler
    >>seems to be gone after the first run.
    >>If I remove the "-ansi -pedantic -Wall" flags, everything works just fine.
    >>But why?

    >
    > Off topic here.


    .... because the C standard doesn't specify what happens to the
    handling of a signal when a signal handler is invoked. Both behaviors
    you're seeing are consistent with what the C standard specifies.
    (It's deliberately vague so that varying existing behaviors are
    permitted.)

    > You should ask in a forum for the platform you're
    > working on, comp.unix.programmer, at a guess. As another guess, you
    > should probably be re-issuing the signal() in the handler. OTOH, you
    > probably should really be using sigaction() <g>. Go ask the experts in
    > comp.unix.programmer.


    Yes, but first read your system's documentation for the signal
    function. <OT>On Unix-like systems, there may be multiple man pages
    for "signal"; "man man" if you don't already know how to find the one
    you need.</OT>

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jun 1, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nut Cracker
    Replies:
    1
    Views:
    331
  2. jakk
    Replies:
    4
    Views:
    12,032
  3. Tim Meagher
    Replies:
    8
    Views:
    1,277
    Karl Seguin
    Jun 18, 2005
  4. Johan

    signalhandler calss

    Johan, Feb 25, 2004, in forum: C++
    Replies:
    1
    Views:
    303
    Jack Klein
    Feb 25, 2004
  5. titi

    if and and vs if and,and

    titi, Mar 9, 2007, in forum: VHDL
    Replies:
    4
    Views:
    566
    Mike Treseler
    Mar 11, 2007
Loading...

Share This Page