Skip to content

Commit

Permalink
fix(*nix): fix zombie process leak
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyRugalev committed Aug 29, 2020
1 parent ae249be commit 8aed565
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"fmt"
"github.com/AnatolyRugalev/kube-commander/app/ui"
"github.com/AnatolyRugalev/kube-commander/app/ui/status"
"github.com/AnatolyRugalev/kube-commander/app/ui/workspace"
Expand Down Expand Up @@ -111,7 +112,7 @@ func (a *app) Run() error {
a.screen = ui.NewScreen(a)
err := a.initScreen()
if err != nil {
return err
return fmt.Errorf("could not initialize screen: %w", err)
}
a.workspace = workspace.NewWorkspace(a, a.defaultNamespace)
err = a.workspace.Init()
Expand Down
4 changes: 2 additions & 2 deletions app/executor/cmd_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (e *executor) renderCommand(command *commander.Command) string {
// execute runs given command in emulated PTY environment
// This is required for cross-platform execution
func (e *executor) runCmd(cmd *exec.Cmd) error {
cmd.SysProcAttr.Setpgid = true
ptmx, err := pty.Start(cmd)
if err != nil {
return fmt.Errorf("could not start PTY terminal: %w", err)
Expand Down Expand Up @@ -74,5 +73,6 @@ func (e *executor) runCmd(cmd *exec.Cmd) error {
if err != nil {
return err
}
return nil
_, err = cmd.Process.Wait()
return err
}
2 changes: 1 addition & 1 deletion cmd/kube-commander/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func run(_ *cobra.Command, _ []string) error {
conf := client.NewDefaultConfig(cfg.kubeconfig, cfg.context, cfg.namespace)
cl, err := client.NewClient(conf)
if err != nil {
return err
return fmt.Errorf("could not initialize kubernetes client: %w", err)
}
b := builder.NewBuilder(conf, cfg.kubectl, cfg.pager, cfg.editor, cfg.tail)
application := app.NewApp(conf, cl, cl, b, executor.NewOsExecutor(), conf.Namespace())
Expand Down

0 comments on commit 8aed565

Please sign in to comment.