Re: Compiling differences?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux