mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
fix nil pointer exception when trying to kill process
This commit is contained in:
parent
588ff79003
commit
345f02eb11
2 changed files with 7 additions and 1 deletions
|
|
@ -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.
|
// 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 {
|
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 {
|
if cmd.SysProcAttr != nil && cmd.SysProcAttr.Setpgid == true {
|
||||||
// minus sign means we're talking about a PGID as opposed to a PID
|
// minus sign means we're talking about a PGID as opposed to a PID
|
||||||
return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
|
return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,9 @@ func (gui *Gui) renderContainerLogs(container *commands.Container) error {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-stop
|
<-stop
|
||||||
cmd.Process.Kill()
|
if err := gui.OSCommand.Kill(cmd); err != nil {
|
||||||
|
gui.Log.Warn(err)
|
||||||
|
}
|
||||||
gui.Log.Info("killed container logs process")
|
gui.Log.Info("killed container logs process")
|
||||||
return
|
return
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue