This is the mail archive of the 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]

signal handler and -fno-optimize-sibling-calls


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 on NetBSD?

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

      $ uname -a
      NetBSD 3.0 NetBSD 3.0 (GENERIC) #0: Fri Feb 24
00:50:03 JST 2006

      $ gcc -v
      Using built-in specs.
      Configured with:
--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.



#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;

      act.sa_flags = SA_SIGINFO;
      act.sa_sigaction= &handle_winch;

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

      for (;;) {

      return 0;


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