diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-10-07 21:19:38 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-10-10 00:23:01 +1100 |
commit | 79e59d5460d838203bc79ac86c0ba529305ba2a9 (patch) | |
tree | 7a7d6c48440f02945599606494ac64424d274f58 /pkg/commands/oscommands | |
parent | ba4c3e5bc475a7819fd954985105073ba239bf9e (diff) |
add some safe goroutines
WIP
Diffstat (limited to 'pkg/commands/oscommands')
-rw-r--r-- | pkg/commands/oscommands/exec_live_default.go | 5 | ||||
-rw-r--r-- | pkg/commands/oscommands/os.go | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/pkg/commands/oscommands/exec_live_default.go b/pkg/commands/oscommands/exec_live_default.go index 2e09e38dd..6f51ecedc 100644 --- a/pkg/commands/oscommands/exec_live_default.go +++ b/pkg/commands/oscommands/exec_live_default.go @@ -9,6 +9,7 @@ import ( "unicode/utf8" "github.com/go-errors/errors" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/creack/pty" ) @@ -31,14 +32,14 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s return err } - go func() { + go utils.Safe(func() { scanner := bufio.NewScanner(ptmx) scanner.Split(scanWordsWithNewLines) for scanner.Scan() { toOutput := strings.Trim(scanner.Text(), " ") _, _ = ptmx.WriteString(output(toOutput)) } - }() + }) err = cmd.Wait() ptmx.Close() diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 3f5076dae..e16a821de 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -411,7 +411,7 @@ func (c *OSCommand) PipeCommands(commandStrings ...string) error { for _, cmd := range cmds { currentCmd := cmd - go func() { + go utils.Safe(func() { stderr, err := currentCmd.StderrPipe() if err != nil { c.Log.Error(err) @@ -432,7 +432,7 @@ func (c *OSCommand) PipeCommands(commandStrings ...string) error { } wg.Done() - }() + }) } wg.Wait() |