@@ -72,10 +72,30 @@ } binary scan $random_bin H* random set srcdir [file join $::starkit::topdir files] set dstdir [file join $tmpdir tcpdump-temp-$random] + +proc cleanup {} { + # Cleanup + catch { + ::twapi::stop_service npf + } + catch { + ::twapi::delete_service npf + } + catch { + file delete -force -- $::dstdir + } +} + +# Install exit handler to cleanup +rename exit _exit +proc exit args { + cleanup + _exit {*}$args +} # Run tcpdump set exit 1 set npf_failed 0 if {[catch {