Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Handle case when waiting is killed, which throws error
Browse files Browse the repository at this point in the history
Fixes #67
  • Loading branch information
LordRalex committed Sep 10, 2018
1 parent 2f744b1 commit 2d4cbf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions environments/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ func (s *standard) standardExecuteAsync(cmd string, args []string, env map[strin
logging.Debugf("Starting process: %s %s", s.mainProcess.Path, strings.Join(s.mainProcess.Args, " "))
err = s.mainProcess.Start()
go func() {
s.mainProcess.Wait()
err := s.mainProcess.Wait()
s.wait.Done()
if callback != nil {
callback(s.mainProcess.ProcessState.Success())
if s.mainProcess == nil || s.mainProcess.ProcessState == nil || err != nil {
callback(false)
} else {
callback(s.mainProcess.ProcessState.Success())
}
}
}()
if err != nil && err.Error() != "exit status 1" {
Expand Down
4 changes: 2 additions & 2 deletions environments/tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (s *tty) ttyExecuteAsync(cmd string, args []string, env map[string]string,
s.stdInWriter = tty
go func() {
io.Copy(wrapper, tty)
process.Wait()
err = process.Wait()
s.wait.Done()
if callback != nil {
if s.mainProcess == nil || s.mainProcess.ProcessState == nil {
if s.mainProcess == nil || s.mainProcess.ProcessState == nil || err != nil {
callback(false)
} else {
callback(s.mainProcess.ProcessState.Success())
Expand Down

0 comments on commit 2d4cbf8

Please sign in to comment.