By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,017 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,017 IT Pros & Developers. It's quick & easy.

Signalhandler and "-ansi -pedantic -Wall"

P: n/a
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 !
May 31 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <as*@me.atwrote:
>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
May 31 '07 #2

P: n/a
Al Balmer wrote:
On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <as*@me.atwrote:
>>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
May 31 '07 #3

P: n/a
In article <46***********************@newsreader02.highway.te lekom.at>,
Simon Klein <as*@me.atwrote:
>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
May 31 '07 #4

P: n/a
On May 31, 5:26 pm, Al Balmer <albal...@att.netwrote:
On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a...@me.atwrote:
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.

May 31 '07 #5

P: n/a
In article <11*********************@p77g2000hsh.googlegroups. com>,
Quentin Godfroy <qu*************@hotmail.comwrote:
>On May 31, 5:26 pm, Al Balmer <albal...@att.netwrote:
>On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a...@me.atwrote:
>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
May 31 '07 #6

P: n/a
On May 31, 5:39 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
On May 31, 5:26 pm, Al Balmer <albal...@att.netwrote:
On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a...@me.atwrote:
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.

May 31 '07 #7

P: n/a
On 31 May 2007 14:36:39 -0700, Quentin Godfroy
<qu*************@hotmail.comwrote:
>On May 31, 5:26 pm, Al Balmer <albal...@att.netwrote:
>On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a...@me.atwrote:
>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
May 31 '07 #8

P: n/a
Al Balmer <al******@att.netwrites:
On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <as*@me.atwrote:
>>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) ks***@mib.org <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"
May 31 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.