diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 1e9d8118..3c420fdd 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -370,6 +370,10 @@ func (c *OSCommand) PipeCommands(commandStrings ...string) error { // Kill kills a process. If the process has Setpgid == true, then we have anticipated that it might spawn its own child processes, so we've given it a process group ID (PGID) equal to its process id (PID) and given its child processes will inherit the PGID, we can kill that group, rather than killing the process itself. func (c *OSCommand) Kill(cmd *exec.Cmd) error { + if cmd.Process == nil { + // somebody got to it before we were able to, poor bastard + return nil + } if cmd.SysProcAttr != nil && cmd.SysProcAttr.Setpgid == true { // minus sign means we're talking about a PGID as opposed to a PID return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL) diff --git a/pkg/gui/containers_panel.go b/pkg/gui/containers_panel.go index 4b5a6135..22ec1d99 100644 --- a/pkg/gui/containers_panel.go +++ b/pkg/gui/containers_panel.go @@ -193,7 +193,9 @@ func (gui *Gui) renderContainerLogs(container *commands.Container) error { go func() { <-stop - cmd.Process.Kill() + if err := gui.OSCommand.Kill(cmd); err != nil { + gui.Log.Warn(err) + } gui.Log.Info("killed container logs process") return }()