From 8d7740a5acabc87b6be98315881dd97e57832220 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 25 Jul 2025 09:02:38 +0200 Subject: [PATCH] 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. --- pkg/tasks/tasks.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 5de7fb232..5401b1714 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -5,12 +5,10 @@ import ( "fmt" "io" "os/exec" - "strings" "sync" "time" "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sasha-s/go-deadlock" "github.com/sirupsen/logrus" @@ -167,14 +165,7 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p // and the user is flicking through a bunch of items. self.throttle = time.Since(startTime) < THROTTLE_TIME && timeToStart > COMMAND_START_THRESHOLD - // Kill the still-running command. - if err := oscommands.Kill(cmd); err != nil { - if !strings.Contains(err.Error(), "process already finished") { - self.Log.Errorf("error when trying to kill cmd task: %v; Command: %v %v", err, cmd.Path, cmd.Args) - } - } - - // for pty's we need to call onDone here so that cmd.Wait() doesn't block forever + // close the task's stdout pipe (or the pty if we're using one) to make the command terminate onDone() } })