This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compiling differences?


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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]