Signalhandler and "-ansi -pedantic -Wall"

S

Simon Klein

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 !
 
S

Simon Klein

Al said:
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
 
A

Al Balmer

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.
 
W

Walter Roberson

Simon Klein said:
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.
 
Q

Quentin Godfroy

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.
 
K

Keith Thompson

Al Balmer said:
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top