@rm -f $@
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
-CSRC = setsignal.c tcpdump.c
+CSRC = tcpdump.c
LIBNETDISSECT_SRC=\
addrtoname.c \
rpc_auth.h \
rpc_msg.h \
rpl.h \
- setsignal.h \
signature.h \
slcompress.h \
smb.h \
])
])
-dnl
-dnl Define RETSIGTYPE and RETSIGVAL
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_TYPE_SIGNAL
-dnl
-dnl results:
-dnl
-dnl RETSIGTYPE (defined)
-dnl RETSIGVAL (defined)
-dnl
-AC_DEFUN(AC_LBL_TYPE_SIGNAL,
- [AC_BEFORE([$0], [AC_LBL_LIBPCAP])
- AC_TYPE_SIGNAL
- if test "$ac_cv_type_signal" = void ; then
- AC_DEFINE(RETSIGVAL,[],[return value of signal handlers])
- else
- AC_DEFINE(RETSIGVAL,(0),[return value of signal handlers])
- fi
- case "$host_os" in
-
- irix*)
- AC_DEFINE(_BSD_SIGNALS,1,[get BSD semantics on Irix])
- ;;
-
- *)
- dnl prefer sigaction() to sigset()
- AC_CHECK_FUNCS(sigaction)
- if test $ac_cv_func_sigaction = no ; then
- AC_CHECK_FUNCS(sigset)
- fi
- ;;
- esac])
-
dnl
dnl If using gcc, make sure we have ANSI ioctl definitions
dnl
#include "addrtostr.h"
#include "ethertype.h"
#include "llc.h"
-#include "setsignal.h"
#include "extract.h"
#include "oui.h"
/* Define to 1 if you have the `setlinebuf' function. */
#undef HAVE_SETLINEBUF
-/* Define to 1 if you have the `sigaction' function. */
-#undef HAVE_SIGACTION
-
-/* Define to 1 if you have the `sigset' function. */
-#undef HAVE_SIGSET
-
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
-/* return value of signal handlers */
-#undef RETSIGVAL
-
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* define if should drop privileges by default */
#undef WITH_USER
-/* get BSD semantics on Irix */
-#undef _BSD_SIGNALS
-
/* define on AIX to get certain functions */
#undef _SUN
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
-$as_echo_n "checking return type of signal handlers... " >&6; }
-if ${ac_cv_type_signal+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <signal.h>
-
-int
-main ()
-{
-return *(signal (0, 0)) (0) == 1;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_type_signal=int
-else
- ac_cv_type_signal=void
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
-$as_echo "$ac_cv_type_signal" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define RETSIGTYPE $ac_cv_type_signal
-_ACEOF
-
-
- if test "$ac_cv_type_signal" = void ; then
-
-$as_echo "#define RETSIGVAL /**/" >>confdefs.h
-
- else
-
-$as_echo "#define RETSIGVAL (0)" >>confdefs.h
-
- fi
- case "$host_os" in
-
- irix*)
-
-$as_echo "#define _BSD_SIGNALS 1" >>confdefs.h
-
- ;;
-
- *)
- for ac_func in sigaction
-do :
- ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction"
-if test "x$ac_cv_func_sigaction" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SIGACTION 1
-_ACEOF
-
-fi
-done
-
- if test $ac_cv_func_sigaction = no ; then
- for ac_func in sigset
-do :
- ac_fn_c_check_func "$LINENO" "sigset" "ac_cv_func_sigset"
-if test "x$ac_cv_func_sigset" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SIGSET 1
-_ACEOF
-
-fi
-done
-
- fi
- ;;
- esac
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5
$as_echo_n "checking for library containing dnet_htoa... " >&6; }
if ${ac_cv_search_dnet_htoa+:} false; then :
AC_LIBOBJ(snprintf)
fi
-AC_LBL_TYPE_SIGNAL
-
AC_SEARCH_LIBS(dnet_htoa, dnet,
AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
#define MAXHOSTNAMELEN 64
#define snprintf _snprintf
#define vsnprintf _vsnprintf
-#define RETSIGTYPE void
#else /* _WIN32 */
+++ /dev/null
-/*
- * Copyright (c) 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <netdissect-stdinc.h>
-
-#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, whenever possible, partial BSD
- * semantics, i.e. the signal handler is restored following service
- * of the signal, but system calls are *not* restarted, so that if
- * "pcap_breakloop()" is called in a signal handler in a live capture,
- * the read/recvfrom/whatever in the live capture doesn't get restarted,
- * it returns -1 and sets "errno" to EINTR, so we can break out of the
- * live capture loop.
- *
- * We use "sigaction()" if available. We don't specify that the signal
- * should restart system calls, so that should always do what we want.
- *
- * Otherwise, if "sigset()" is available, it probably has BSD semantics
- * while "signal()" has traditional semantics, so we use "sigset()"; it
- * might cause system calls to be restarted for the signal, however.
- * I don't know whether, in any systems where it did cause system calls to
- * be restarted, there was a way to ask it not to do so; there may no
- * longer be any interesting systems without "sigaction()", however,
- * and, if there are, they might have "sigvec()" with SV_INTERRUPT
- * (which I think first appeared in 4.3BSD).
- *
- * Otherwise, we use "signal()" - which means we might get traditional
- * semantics, wherein system calls don't get restarted *but* the
- * signal handler is reset to SIG_DFL and the signal is not blocked,
- * so that a subsequent signal would kill the process immediately.
- *
- * Did I mention that signals suck? At least in POSIX-compliant systems
- * they suck far less, as those systems have "sigaction()".
- */
-RETSIGTYPE
-(*setsignal (int sig, RETSIGTYPE (*func)(int)))(int)
-{
-#ifdef HAVE_SIGACTION
- struct sigaction old, new;
-
- memset(&new, 0, sizeof(new));
- new.sa_handler = func;
- if (sig == SIGCHLD)
- new.sa_flags = SA_RESTART;
- 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
-}
-
+++ /dev/null
-/*
- * Copyright (c) 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#ifndef setsignal_h
-#define setsignal_h
-
-RETSIGTYPE (*setsignal(int, RETSIGTYPE (*)(int)))(int);
-#endif
#include "interface.h"
#include "addrtoname.h"
#include "machdep.h"
-#include "setsignal.h"
#include "gmt2local.h"
#include "pcap-missing.h"
#include "ascii_strcasecmp.h"
static NORETURN void error(FORMAT_STRING(const char *), ...) PRINTFLIKE(1, 2);
static void warning(FORMAT_STRING(const char *), ...) PRINTFLIKE(1, 2);
static NORETURN void exit_tcpdump(int);
-static RETSIGTYPE cleanup(int);
-static RETSIGTYPE child_cleanup(int);
+static void (*setsignal (int sig, void (*func)(int)))(int);
+static void cleanup(int);
+static void child_cleanup(int);
static void print_version(void);
static void print_usage(void);
static NORETURN void show_tstamp_types_and_exit(pcap_t *, const char *device);
static void droproot(const char *, const char *);
#ifdef SIGNAL_REQ_INFO
-RETSIGTYPE requestinfo(int);
+void requestinfo(int);
#endif
#if defined(USE_WIN32_MM_TIMER)
const char *dlt_name;
struct bpf_program fcode;
#ifndef _WIN32
- RETSIGTYPE (*oldhandler)(int);
+ void (*oldhandler)(int);
#endif
struct dump_info dumpinfo;
u_char *pcap_userdata;
exit_tcpdump(status == -1 ? 1 : 0);
}
+/*
+ * Catch a signal.
+ */
+static void
+(*setsignal (int sig, void (*func)(int)))(int)
+{
+#ifdef _WIN32
+ return (signal(sig, func));
+#else
+ struct sigaction old, new;
+
+ memset(&new, 0, sizeof(new));
+ new.sa_handler = func;
+ if (sig == SIGCHLD)
+ new.sa_flags = SA_RESTART;
+ if (sigaction(sig, &new, &old) < 0)
+ return (SIG_ERR);
+ return (old.sa_handler);
+#endif
+}
+
/* make a clean exit on interrupts */
-static RETSIGTYPE
+static void
cleanup(int signo _U_)
{
#ifdef USE_WIN32_MM_TIMER
waiting a child processes to die
*/
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
-static RETSIGTYPE
+static void
child_cleanup(int signo _U_)
{
wait(NULL);
#endif
#ifdef SIGNAL_REQ_INFO
-RETSIGTYPE requestinfo(int signo _U_)
+void requestinfo(int signo _U_)
{
if (infodelay)
++infoprint;