diff options
| -rw-r--r-- | config.h.in | 6 | ||||
| -rwxr-xr-x | configure | 4 | ||||
| -rw-r--r-- | configure.in | 2 | ||||
| -rw-r--r-- | tcpdump.c | 25 |
4 files changed, 28 insertions, 9 deletions
diff --git a/config.h.in b/config.h.in index 3be38477..3086710c 100644 --- a/config.h.in +++ b/config.h.in @@ -105,6 +105,9 @@ /* Define to 1 if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + /* Define to 1 if you have the `getnameinfo' function. */ #undef HAVE_GETNAMEINFO @@ -237,6 +240,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + /* Define to 1 if you have the `vfprintf' function. */ #undef HAVE_VFPRINTF @@ -6138,7 +6138,9 @@ done -for ac_func in strftime + + +for ac_func in fork vfork strftime do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 6fa27cc9..e2d41703 100644 --- a/configure.in +++ b/configure.in @@ -549,7 +549,7 @@ AC_STRUCT_RES_STATE(ac_cv_res_state) AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep) -AC_CHECK_FUNCS(strftime) +AC_CHECK_FUNCS(fork vfork strftime) AC_CHECK_FUNCS(setlinebuf alarm) needsnprintf=no @@ -1250,8 +1250,10 @@ main(int argc, char **argv) (void)setsignal(SIGPIPE, cleanup); (void)setsignal(SIGTERM, cleanup); (void)setsignal(SIGINT, cleanup); - (void)setsignal(SIGCHLD, child_cleanup); #endif /* WIN32 */ +#if defined(HAVE_FORK) || defined(HAVE_VFORK) + (void)setsignal(SIGCHLD, child_cleanup); +#endif /* Cooperate with nohup(1) */ #ifndef WIN32 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) @@ -1464,13 +1466,13 @@ cleanup(int signo _U_) On windows, we do not use a fork, so we do not care less about waiting a child processes to die */ -#ifndef WIN32 +#if defined(HAVE_FORK) || defined(HAVE_VFORK) static RETSIGTYPE child_cleanup(int signo _U_) { wait(NULL); } -#endif /* WIN32 */ +#endif /* HAVE_FORK && HAVE_VFORK */ static void info(register int verbose) @@ -1514,11 +1516,15 @@ info(register int verbose) infoprint = 0; } -#ifndef WIN32 +#if defined(HAVE_FORK) || defined(HAVE_VFORK) static void compress_savefile(const char *filename) { +# ifdef HAVE_FORK if (fork()) +# else + if (vfork()) +# endif return; /* * Set to lowest priority so that this doesn't disturb the capture @@ -1534,15 +1540,20 @@ compress_savefile(const char *filename) zflag, filename, strerror(errno)); +# ifdef HAVE_FORK + exit(1); +# else + _exit(1); +# endif } -#else /* WIN32 */ +#else /* HAVE_FORK && HAVE_VFORK */ static void compress_savefile(const char *filename) { fprintf(stderr, - "compress_savefile failed. Functionality not implemented under windows\n"); + "compress_savefile failed. Functionality not implemented under your system\n"); } -#endif /* WIN32 */ +#endif /* HAVE_FORK && HAVE_VFORK */ static void dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) |
