commit c7737223bb1ed9f6944a5020db5ed527b25efd97 Author: David Fifield david@bamsoftware.com Date: Thu Apr 18 23:23:08 2019 -0600
Terminate firefox and meek-client simultaneously.
Let both their terminateTimeouts run concurrently. --- meek-client-torbrowser/meek-client-torbrowser.go | 41 +++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go index 7c304ea..38a9fc3 100644 --- a/meek-client-torbrowser/meek-client-torbrowser.go +++ b/meek-client-torbrowser/meek-client-torbrowser.go @@ -34,6 +34,7 @@ import ( "path/filepath" "regexp" "strings" + "sync" "syscall" "time" ) @@ -413,25 +414,35 @@ func main() { log.Print(err) }
+ var wg sync.WaitGroup if firefoxCmd != nil { - err := terminateCmd(firefoxCmd) - // We terminate Firefox with SIGTERM, so don't log an error - // if the exit status is "terminated by SIGTERM." - if err2, ok := err.(*exec.ExitError); ok { - if status, ok := err2.Sys().(syscall.WaitStatus); ok { - if status.Signaled() && status.Signal() == syscall.SIGTERM { - err = nil + wg.Add(1) + go func() { + defer wg.Done() + err := terminateCmd(firefoxCmd) + // We terminate Firefox with SIGTERM, so don't log an + // error if the exit status is "terminated by SIGTERM." + if err2, ok := err.(*exec.ExitError); ok { + if status, ok := err2.Sys().(syscall.WaitStatus); ok { + if status.Signaled() && status.Signal() == syscall.SIGTERM { + err = nil + } } } - } - if err != nil { - log.Printf("error terminating firefox: %v", err) - } + if err != nil { + log.Printf("error terminating firefox: %v", err) + } + }() } if meekClientCmd != nil { - err := terminatePTCmd(meekClientCmd) - if err != nil { - log.Printf("error terminating meek-client: %v", err) - } + wg.Add(1) + go func() { + defer wg.Done() + err := terminatePTCmd(meekClientCmd) + if err != nil { + log.Printf("error terminating meek-client: %v", err) + } + }() } + wg.Wait() }