Skip to content

Commit 8d7740a

Browse files
committed
Don't kill tasks when we no longer need them
Now that we close a task's stdout pipe when we are done with it, it should terminate by itself at that point, so there's no longer a need to kill it. This way, called processes get a chance to terminate gracefully rather than being killed with SIGKILL; in particular, this allows git to clean up its index.lock file if it created one.
1 parent d0a10ba commit 8d7740a

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

pkg/tasks/tasks.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import (
55
"fmt"
66
"io"
77
"os/exec"
8-
"strings"
98
"sync"
109
"time"
1110

1211
"github.com/jesseduffield/gocui"
13-
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
1412
"github.com/jesseduffield/lazygit/pkg/utils"
1513
"github.com/sasha-s/go-deadlock"
1614
"github.com/sirupsen/logrus"
@@ -167,14 +165,7 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p
167165
// and the user is flicking through a bunch of items.
168166
self.throttle = time.Since(startTime) < THROTTLE_TIME && timeToStart > COMMAND_START_THRESHOLD
169167

170-
// Kill the still-running command.
171-
if err := oscommands.Kill(cmd); err != nil {
172-
if !strings.Contains(err.Error(), "process already finished") {
173-
self.Log.Errorf("error when trying to kill cmd task: %v; Command: %v %v", err, cmd.Path, cmd.Args)
174-
}
175-
}
176-
177-
// for pty's we need to call onDone here so that cmd.Wait() doesn't block forever
168+
// close the task's stdout pipe (or the pty if we're using one) to make the command terminate
178169
onDone()
179170
}
180171
})

0 commit comments

Comments
 (0)