Subject: program built with -O2 exits on receiving SIGWINCH
To: None <netbsd-users@netbsd.org>
From: Hiroshi SAKURAI <an.olive.tree@gmail.com>
List: netbsd-users
Date: 02/26/2006 00:10:58
Hi,

I'm using NetBSD3.0.

Following program exits when it receives SIGWINCH signal
if built with -O2.

=09$ gcc -Wall -O2 -g a.c
=09$ ./a.out &
=09[1] 15605
=09$ pkill -WINCH a.out
=09[1]+ Done       ./a.out

If built with -O1, it does not exit when receiving SIGWINCH.

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

Am I doing something wrong?
Here's a output of uname and gcc -v.

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

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


Thanks.


=3D=3D=3D=3D=3D=3D=3D=3D=3D

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

int a;

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

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

int main(void)
{
=09struct sigaction act;

=09sigemptyset(&act.sa_mask);
=09act.sa_handler=3DSIG_IGN;
=09act.sa_flags =3D SA_SIGINFO;
=09act.sa_sigaction=3D &handle_winch;

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

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

=09return 0;
}

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