Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #120 reports that if you hit ctrl-c shortly after startup, occasionally termshark will not quit correctly, and subsequent ctrl-c invocations make no difference. This occurs only if reading from an interface. In that case, the PSML-reading process starts with stdin set to the read-end of a pipe. That pipe is supplied with pcap data via a tail command, reading from the gradually accumulating pcap on disk. The goroutine that tracks changes to PSML process state needs to ensure that if the controlling context is cancelled, this pipe is closed. Failing to do this can lead to Go's cmd.Exec never responding to Wait() because internally, the Wait() calls itself waits for a private goroutine - that goroutine is running io.Copy() from the user's process IO reader (our pipe) to the real process's stdin. Closing the pipe will cause io.Copy() to terminate, then cmd.Exec's private goroutine to terminate, and so allows Wait() to return a value.
- Loading branch information