ipropd_common.c revision 302408
113547Sjulian/*
213547Sjulian * Copyright (c) 1997 - 2007 Kungliga Tekniska H��gskolan
335025Sjb * (Royal Institute of Technology, Stockholm, Sweden).
413547Sjulian * All rights reserved.
513547Sjulian *
613547Sjulian * Redistribution and use in source and binary forms, with or without
713547Sjulian * modification, are permitted provided that the following conditions
813547Sjulian * are met:
913547Sjulian *
1013547Sjulian * 1. Redistributions of source code must retain the above copyright
1113547Sjulian *    notice, this list of conditions and the following disclaimer.
1213547Sjulian *
1313547Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1413547Sjulian *    notice, this list of conditions and the following disclaimer in the
1513547Sjulian *    documentation and/or other materials provided with the distribution.
1613547Sjulian *
1713547Sjulian * 3. Neither the name of the Institute nor the names of its contributors
1813547Sjulian *    may be used to endorse or promote products derived from this software
1913547Sjulian *    without specific prior written permission.
2013547Sjulian *
2113547Sjulian * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
2213547Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2313547Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2413547Sjulian * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
2513547Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2613547Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2713547Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2813547Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2913547Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3013547Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3113547Sjulian * SUCH DAMAGE.
3213547Sjulian */
3350473Speter
3413547Sjulian#include "iprop.h"
3513547SjulianRCSID("$Id$");
3613547Sjulian
3713547Sjuliansig_atomic_t exit_flag;
3813547Sjulian
3913547Sjulianstatic RETSIGTYPE
4013547Sjuliansigterm(int sig)
4113547Sjulian{
4213547Sjulian    exit_flag = sig;
4313547Sjulian}
4417706Sjulian
4517706Sjulianvoid
4644965Sjbsetup_signal(void)
4713547Sjulian{
4813547Sjulian#ifdef HAVE_SIGACTION
4917706Sjulian    {
5013547Sjulian	struct sigaction sa;
5117706Sjulian
5217706Sjulian	sa.sa_flags = 0;
5317706Sjulian	sa.sa_handler = sigterm;
5417706Sjulian	sigemptyset(&sa.sa_mask);
55119736Sdavidxu
5613547Sjulian	sigaction(SIGINT, &sa, NULL);
5713547Sjulian	sigaction(SIGTERM, &sa, NULL);
5822315Sjulian	sigaction(SIGXCPU, &sa, NULL);
5922315Sjulian
6022315Sjulian	sa.sa_handler = SIG_IGN;
6122315Sjulian	sigaction(SIGPIPE, &sa, NULL);
6222315Sjulian    }
6322315Sjulian#else
6422315Sjulian    signal(SIGINT, sigterm);
6522315Sjulian    signal(SIGTERM, sigterm);
6622315Sjulian#ifndef NO_SIGXCPU
6722315Sjulian    signal(SIGXCPU, sigterm);
6822315Sjulian#endif
6922315Sjulian#ifndef NO_SIGPIPE
7022315Sjulian    signal(SIGPIPE, SIG_IGN);
7138919Salex#endif
7238919Salex#endif
7338919Salex}
7438919Salex