X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fblackbox%2Fcommon%2Ftcpdump.c;h=1d9b23f9762919fdaed69a0953a13f2cf4919ff1;hb=refs%2Fheads%2Ffeature%2Fhuge-udp-channel-packets;hp=7839a422955e5c817801bb082a447e1f5c769f29;hpb=1c04402a6d2f3a85d0cb4a5b4a6db5b1f3a79511;p=meshlink diff --git a/test/blackbox/common/tcpdump.c b/test/blackbox/common/tcpdump.c index 7839a422..1d9b23f9 100644 --- a/test/blackbox/common/tcpdump.c +++ b/test/blackbox/common/tcpdump.c @@ -17,26 +17,32 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#ifdef NDEBUG +#undef NDEBUG +#endif + #include #include #include #include #include +#include #include #include #include "common_handlers.h" -#include "containers.h" #include "tcpdump.h" pid_t tcpdump_start(char *interface) { - pid_t tcpdump_pid; char *argv[] = { "tcpdump", "-i", interface, NULL }; // child process have a pipe to the parent process when parent process terminates SIGPIPE kills the tcpdump int pipes[2]; assert(pipe(pipes) != -1); PRINT_TEST_CASE_MSG("\x1b[32mLaunching TCP Dump ..\x1b[0m\n"); - if((tcpdump_pid = fork()) == 0) { + pid_t tcpdump_pid = fork(); + + if(tcpdump_pid == 0) { prctl(PR_SET_PDEATHSIG, SIGHUP); close(pipes[1]); // Open log file for TCP Dump @@ -46,13 +52,14 @@ pid_t tcpdump_start(char *interface) { assert(dup2(fd, STDOUT_FILENO) != -1); // Launch TCPDump with port numbers of sleepy, gateway & relay - int ret = execvp("/usr/sbin/tcpdump", argv); + execvp("/usr/sbin/tcpdump", argv); perror("execvp "); - assert(ret != -1); + exit(1); } else { close(pipes[0]); - return tcpdump_pid; } + + return tcpdump_pid; } void tcpdump_stop(pid_t tcpdump_pid) {