Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

Signalhandler and "-ansi -pedantic -Wall"


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 !

On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a@me.at> 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

thx and sorry for the offtopic post
In article <465f399c$0$25625$91cee@newsreader02.highway.telekom.at>,
Simon Klein  <a@me.at> 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

On May 31, 5:26 pm, Al Balmer <albal@att.net> wrote:

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.

In article <1180647399.010236.59@p77g2000hsh.googlegroups.com>,
Quentin Godfroy  <quentin_godf@hotmail.com> wrote:

>On May 31, 5:26 pm, Al Balmer <albal@att.net> wrote:
>> On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a@me.at> 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
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.net> wrote:
> >> On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a@me.at> 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.
On 31 May 2007 14:36:39 -0700, Quentin Godfroy

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 <albal@att.net> writes:
> On Thu, 31 May 2007 23:01:02 +0200, Simon Klein <a@me.at> 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) k@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"

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc