public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Muthukumar Ratty <muthu@iqmail.net>
To: Matias Bordese <bordese@hal.famaf.unc.edu.ar>
Cc: <gcc@gcc.gnu.org>, <gcc-help@gcc.gnu.org>
Subject: Re: Compiling differences?
Date: Thu, 13 May 2004 02:15:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.33.0405121903430.23763-100000@Muruga.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0405121913540.1673-200000@hp14.labcomp.famaf.unc.edu.ar>


Hi,
This is due to the ansi signal specification. It sets the signal handler
to SIG_DFL before executing the current handler( your). So the next signal
terminates the process (so you see "Alarm clock" message). If you dont
specify ansi standard then your handler is always executed.

The right way to do this is to use signal in your handler again
i.e

void s_handler (int signum)
{
        signal(SIGALRM, s_handler);
        if (signum==SIGALRM){
                printf("\nPlazo vencido\n");
        }
}


I would like to know where this magic is happening. I guess libc calls
differ but not sure :)

Muthu.



On Wed, 12 May 2004, Matias Bordese wrote:

>
> I was using the setitimer function (libc 2.2.4) and according to the
> options I compile with (with gcc 2.96), I got different behaviors
> (besides, the binaries differ too):
>
> gcc -o timer -Wall -ansi -pedantic timers.c
> (I get the message: "Alarm clock", and the program finishes)
>
> and
>
> gcc -o timer2 timers.c
> (I get the expected behavior)
>
> 	Matias
>
> PD.: The file is attached.
> PD2.: Sorry for my poor English.
>




      reply	other threads:[~2004-05-13  2:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-12 22:25 Matias Bordese
2004-05-13  2:15 ` Muthukumar Ratty [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=Pine.LNX.4.33.0405121903430.23763-100000@Muruga.localdomain \
    --to=muthu@iqmail.net \
    --cc=bordese@hal.famaf.unc.edu.ar \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).