/** * @brief Exit function (closes the capture handle and releases all resource from libntoh) */ void shandler ( int sign ) { if ( sign != 0 ) signal ( sign , &shandler ); pcap_close( handle ); ntoh_exit(); fprintf( stderr, "\n\n[+] Capture finished!\n" ); exit( sign ); }
/** * @brief Exit function (closes the capture handle and releases all resource from libntoh) */ void shandler ( int sign ) { signal( SIGINT, &shandler ); signal( SIGTERM, &shandler ); signal( SIGSEGV, &shandler ); snc.smem.shm[CTL][FLAGS] = PDONE; kill(ret_pid, SIGINT); uint32_t len = 0; if (DEBUG) { if (snc.smem.shm[CTL][FLAGS] == CDONE) { strncpy(buf, "\n\t\t[i] --- Signaled to quit by consumer\n", 40); write(2, buf, 40); } strncpy(buf, "\n\t\t[i] --- Signal: ", 19); tmp = itoa(sign); len = strlen(tmp); strncat(buf, tmp, len); len += 19; write(2, buf, len); } freeMem(&snc); if (t5Convert) { free(t5Convert); } pcap_close( handle ); ntoh_exit(); strncpy(buf, "\n\t\tX ----- Inactive ----- X\n\n", 43); write(2, buf, 43); exit(sign); }