Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug that could cause a hang at shutdown
The new search widget is created during ui.Build(), which always runs. That means the search widget needs to be closed, whether termshark starts successfully or not. During normal operation, with the UI running, a message is sent to a "quit" channel and the main select{} loop in termshark.go will call Close() on the widgets with extra goroutines and other resources. I included the search widget in that list. But if termshark doesn't get to the point of the UI running, these Close() functions are not called. For the cases I have, it doesn't *really* matter because these would just leave dangling goroutines at shutdown - no harm done. But termshark tries to clean up every resource it creates just as matter of good practice, and if goroutines are left unterminated, the main process will deliberately hang at shutdown (so I can detect that). Termshark can bail out after the UI creation but before the UI launches if e.g. the launching user does not have permission to sniff on an interface: foobar@elgin:~$ /home/gcla/go/bin/termshark --debug -i 3 (The termshark UI will start when packets are detected on Random packet generator...) Cannot capture on device Random packet generator: exit status 1 (exit code 1) You might need: sudo setcap cap_net_raw,cap_net_admin+eip /home/gcla/go/bin/termshark Or try running with sudo or as root. See https://termshark.io/no-root for more info.
- Loading branch information