-# $OpenBSD: Makefile,v 1.58 2015/10/13 14:36:15 stsp Exp $
+# $OpenBSD: Makefile,v 1.59 2015/10/14 04:55:17 guenther Exp $
#
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
# The Regents of the University of California. All rights reserved.
# for pcap-int.h
CFLAGS+=-I${.CURDIR}/../../lib/libpcap
-CFLAGS+=-DCSLIP -DPPP -DHAVE_FDDI -DETHER_SERVICE -DRETSIGTYPE=void -DHAVE_NET_SLIP_H -DHAVE_ETHER_NTOHOST -DINET6
+CFLAGS+=-DCSLIP -DPPP -DHAVE_FDDI -DETHER_SERVICE -DHAVE_NET_SLIP_H -DHAVE_ETHER_NTOHOST -DINET6
LDADD+= -lpcap -ll -lcrypto
DPADD+= ${LIBL} ${LIBPCAP} ${LIBCRYPTO}
-/* $OpenBSD: setsignal.c,v 1.5 2015/04/05 17:02:57 guenther Exp $ */
+/* $OpenBSD: setsignal.c,v 1.6 2015/10/14 04:55:17 guenther Exp $ */
/*
* Copyright (c) 1997
#include <sys/types.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <signal.h>
-#ifdef HAVE_SIGACTION
#include <string.h>
-#endif
-
-#ifdef HAVE_OS_PROTO_H
-#include "os-proto.h"
-#endif
#include "setsignal.h"
-/*
- * An os independent signal() with BSD semantics, e.g. the signal
- * catcher is restored following service of the signal.
- *
- * When sigset() is available, signal() has SYSV semantics and sigset()
- * has BSD semantics and call interface. Unfortunately, Linux does not
- * have sigset() so we use the more complicated sigaction() interface
- * there.
- *
- * Did I mention that signals suck?
- */
-RETSIGTYPE
-(*setsignal (int sig, RETSIGTYPE (*func)(int)))(int)
+void
+setsignal(int sig, void (*func)(int))
{
-#ifdef HAVE_SIGACTION
- struct sigaction old, new;
-
- memset(&new, 0, sizeof(new));
- new.sa_handler = func;
-#ifdef SA_RESTART
- new.sa_flags |= SA_RESTART;
-#endif
- if (sigaction(sig, &new, &old) < 0)
- return (SIG_ERR);
- return (old.sa_handler);
-
-#else
-#ifdef HAVE_SIGSET
- return (sigset(sig, func));
-#else
- return (signal(sig, func));
-#endif
-#endif
+ struct sigaction sa;
+
+ if (sigaction(sig, NULL, &sa) == 0 && sa.sa_handler != SIG_IGN) {
+ sa.sa_handler = func;
+ sa.sa_flags = SA_RESTART;
+ if (sig == SIGCHLD)
+ sa.sa_flags |= SA_NOCLDSTOP;
+ sigemptyset(&sa.sa_mask);
+ sigaction(sig, &sa, NULL);
+ }
}
-/* $OpenBSD: setsignal.h,v 1.3 2007/10/07 16:41:05 deraadt Exp $ */
+/* $OpenBSD: setsignal.h,v 1.4 2015/10/14 04:55:17 guenther Exp $ */
/*
* Copyright (c) 1997
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Id: setsignal.h,v 1.3 2007/10/07 16:41:05 deraadt Exp $ (LBL)
+ * @(#) $Id: setsignal.h,v 1.4 2015/10/14 04:55:17 guenther Exp $ (LBL)
*/
#ifndef setsignal_h
#define setsignal_h
-RETSIGTYPE (*setsignal(int, RETSIGTYPE (*)(int)))(int);
+void setsignal(int, void (*)(int));
#endif
-/* $OpenBSD: tcpdump.c,v 1.74 2015/10/09 01:37:09 deraadt Exp $ */
+/* $OpenBSD: tcpdump.c,v 1.75 2015/10/14 04:55:17 guenther Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
extern int esp_init(char *);
/* Forwards */
-RETSIGTYPE cleanup(int);
-RETSIGTYPE gotchld(int);
+void cleanup(int);
+void gotchld(int);
extern __dead void usage(void);
/* Length of saved portion of packet. */
}
/* make a clean exit on interrupts */
-/* ARGSUSED */
-RETSIGTYPE
+void
cleanup(int signo)
{
struct pcap_stat stat;
_exit(0);
}
-/* ARGSUSED */
-RETSIGTYPE
+void
gotchld(int signo)
{
pid_t pid;
void
set_slave_signals(void)
{
- RETSIGTYPE (*oldhandler)(int);
-
setsignal(SIGTERM, cleanup);
setsignal(SIGINT, cleanup);
setsignal(SIGCHLD, gotchld);
- /* Cooperate with nohup(1) XXX is this still necessary/working? */
- if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
- (void)setsignal(SIGHUP, oldhandler);
+ setsignal(SIGHUP, cleanup);
}
__dead void