public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* signal handerl and -fno-optimize-sibling-calls
@ 2006-03-02  3:40 Hiroshi SAKURAI
  0 siblings, 0 replies; only message in thread
From: Hiroshi SAKURAI @ 2006-03-02  3:40 UTC (permalink / raw)
  To: gcc-help

Hi,

I'm using NetBSD3.0 and gcc3.3.3.

Following program exits when it receives SIGWINCH signal
if built with -foptimize-sibling-calls.

       $ gcc -Wall -foptimize-sibling-calls -g a.c
       $ ./a.out &
       [1] 15605
       $ pkill -WINCH a.out
       [1]+ Done       ./a.out

If built without -foptimize-sibling-calls, it does not exit when
receiving SIGWINCH.

       $ gcc -Wall -g a.c
       $ ./a.out &
       [1] 15605
       $ pkill -WINCH a.out
       $

With -foptimize-sibling-calls, a.out ended up calling setcontext(0) and exits.

Is this a bug of gcc or this optimization flag cannot be used to
compile signal handler?

Here's a output of uname and gcc -v.

       $ uname -a
       NetBSD tomato.odn.ne.jp 3.0 NetBSD 3.0 (GENERIC) #0: Fri Feb 24
00:50:03 JST 2006
sakurai@tomato.odn.ne.jp:/usr/home/sakurai/src/obj/sys/arch/i386/compile/GENERIC
i386

       $ gcc -v
       Using built-in specs.
       Configured with:
/home/nick/work/netbsd/src/tools/gcc/../../gnu/dist/gcc/configure
--enable-long-long --disable-multilib --enable-threads
--disable-symvers --build=i386-unknown-netbsdelf2.0.
--host=i386--netbsdelf --target=i386--netbsdelf
       Thread model: posix
       gcc version 3.3.3 (NetBSD nb3 20040520)


I'm not a member of the list so please CC: me.

Thanks.


=========

#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

int a;

void func( int sig, siginfo_t *info, void *context )
{
       a = sig;
}

void handle_winch( int sig, siginfo_t *info, void *context )
{
       func(sig, 0, 0);
}

int main(void)
{
       struct sigaction act;

       sigemptyset(&act.sa_mask);
       act.sa_handler=SIG_IGN;
       act.sa_flags = SA_SIGINFO;
       act.sa_sigaction= &handle_winch;

       if (sigaction(SIGWINCH, &act, 0) != 0) {
               exit (1);
       }

       for (;;) {
               sleep(1);
       }

       return 0;
}

=========
--
Hiroshi SAKURAI
http://vimrc.hp.infoseek.co.jp/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-03-02  3:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-02  3:40 signal handerl and -fno-optimize-sibling-calls Hiroshi SAKURAI

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