diff -u3 -H -B -w nmap-3.51-TEST2/main.cc ./main.cc --- nmap-3.51-TEST2/main.cc Thu Sep 11 04:12:57 2003 +++ ./main.cc Tue Mar 30 15:07:44 2004 @@ -121,6 +121,7 @@ /* global options */ extern NmapOps o; /* option structure */ extern char **environ; +extern void infosigdie(int signo); int main(int argc, char *argv[], char *envp[]) { /* The "real" main is nmap_main(). This function hijacks control at the @@ -176,12 +177,13 @@ /* Trap these sigs for cleanup */ #if HAVE_SIGNAL - signal(SIGINT, sigdie); - signal(SIGTERM, sigdie); + signal(SIGINT, infosigdie); + signal(SIGTERM, infosigdie); +#ifndef WIN32 signal(SIGHUP, sigdie); - signal(SIGCHLD, reaper); #endif +#endif /* First we figure out whether the name nmap is called as qualifies it for interactive mode treatment */ @@ -333,7 +335,9 @@ #if HAVE_SIGNAL signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); +#ifndef WIN32 signal(SIGHUP, SIG_DFL); +#endif signal(SIGSEGV, SIG_DFL); #endif diff -u3 -H -B -w nmap-3.51-TEST2/nmap.cc ./nmap.cc --- nmap-3.51-TEST2/nmap.cc Thu Mar 04 05:16:10 2004 +++ ./nmap.cc Tue Mar 30 15:27:39 2004 @@ -100,6 +100,7 @@ #ifdef __amigaos__ extern void CloseLibs(void); #endif +Target *currenths; /* parse the --scanflags argument. It can be a number >=0 or a string consisting of TCP flag names like "URGPSHFIN". Returns -1 if the argument is invalid. */ static int parse_scanflags(char *arg) { @@ -202,7 +203,6 @@ #endif struct hostent *target = NULL; char **fakeargv; - Target *currenths; char *proberr; char emptystring[1]; int sourceaddrwarning = 0; /* Have we warned them yet about unguessable @@ -848,7 +848,7 @@ } } -#if HAVE_SIGNAL +#if defined(HAVE_SIGNAL) && !defined(WIN32) signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE so our program doesn't crash because of it, but we really shouldn't get an unsuspected SIGPIPE */ @@ -1905,6 +1905,8 @@ } } +#endif + void sigdie(int signo) { int abt = 0; @@ -1915,17 +1917,19 @@ case SIGTERM: fprintf(stderr, "caught SIGTERM signal, cleaning up\n"); break; +#ifndef WIN32 case SIGHUP: fprintf(stderr, "caught SIGHUP signal, cleaning up\n"); break; - case SIGSEGV: - fprintf(stderr, "caught SIGSEGV signal, cleaning up\n"); - abt = 1; - break; case SIGBUS: fprintf(stderr, "caught SIGBUS signal, cleaning up\n"); abt = 1; break; +#endif + case SIGSEGV: + fprintf(stderr, "caught SIGSEGV signal, cleaning up\n"); + abt = 1; + break; default: fprintf(stderr, "caught signal %d, cleaning up\n", signo); abt = 1; @@ -1937,7 +1941,23 @@ exit(1); } -#endif + +void +infosigdie(int signo) +{ + static int counter = 2; + + signal (signo, infosigdie); + fprintf(stderr, "So far we have:\n"); + printportoutput(currenths, ¤ths->ports); + fflush(stdout); + if (counter == 0) { + log_close(LOG_MACHINE|LOG_NORMAL|LOG_SKID); + exit(1); + } + fprintf(stderr, "Ctrl-C %d more times to terminate\n", counter--); +} + int nmap_fetchfile(char *filename_returned, int bufferlen, char *file) { char *dirptr; diff -u3 -H -B -w nmap-3.51-TEST2/service_scan.cc ./service_scan.cc --- nmap-3.51-TEST2/service_scan.cc Mon Mar 08 03:32:36 2004 +++ ./service_scan.cc Tue Mar 30 15:10:26 2004 @@ -1108,7 +1108,7 @@ softMatchFound = false; servicefplen = servicefpalloc = 0; servicefp = NULL; - bzero(¤tprobe_exec_time, sizeof(currentprobe_exec_time)); + memset(¤tprobe_exec_time, 0, sizeof(currentprobe_exec_time)); } ServiceNFO::~ServiceNFO() { diff -u3 -H -B -w nmap-3.51-TEST2/tcpip.cc ./tcpip.cc --- nmap-3.51-TEST2/tcpip.cc Sat Sep 20 11:03:00 2003 +++ ./tcpip.cc Tue Mar 30 15:11:14 2004 @@ -468,7 +468,7 @@ } if (!((pt = pcap_open_live(ifentry->pcapname, snaplen, promisc, to_ms, err0r)))) - fatal("pcap_open_live: %s"); + fatal("pcap_open_live: %s", err0r); // This should help diff -u3 -H -B -w nmap-3.51-TEST2/tcpip.h ./tcpip.h --- nmap-3.51-TEST2/tcpip.h Sat Sep 20 11:03:00 2003 +++ ./tcpip.h Tue Mar 30 15:06:29 2004 @@ -218,13 +218,14 @@ #include #include -#include #if HAVE_SYS_SOCKIO_H #include /* SIOCGIFCONF for Solaris */ #endif #endif /* WIN32 */ +#include + #include "nmap_error.h" #include "utils.h" #include "nmap.h"