Skip to content

Commit

Permalink
Merge pull request #52 from mysteriumnetwork/feature/wait-for-exit
Browse files Browse the repository at this point in the history
CmdWrapper.Stop() blocks until command fully exits
  • Loading branch information
Waldz committed Mar 2, 2020
2 parents a4ebc12 + 5f7c782 commit 9a181e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openvpn/cmd_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (cw *CmdWrapper) outputToLog(output io.ReadCloser, streamPrefix string) {
func (cw *CmdWrapper) waitForExit(cmd *exec.Cmd) {
err := cmd.Wait()
cw.CmdExitError <- err
close(cw.CmdExitError)
}

func (cw *CmdWrapper) waitForShutdown(cmd *exec.Cmd) {
Expand All @@ -129,4 +130,7 @@ func (cw *CmdWrapper) waitForShutdown(cmd *exec.Cmd) {
if err := cmd.Process.Signal(exitSignal); err != nil {
log.Error(cw.logPrefix, "Error killing cw:", err)
}

// Wait for command to quit
<-cw.CmdExitError
}

0 comments on commit 9a181e8

Please sign in to comment.