Skip to content

Commit

Permalink
Revert "rdctl: Don't use process groups on Linux"
Browse files Browse the repository at this point in the history
This reverts commit ea31ee9.  Now that we
manually sets process groups on Linux (in the previous commit), we can
turn its use back on.

Signed-off-by: Mark Yen <mark.yen@suse.com>
  • Loading branch information
mook-as committed Dec 25, 2024
1 parent 2ddd7a3 commit ef273a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
7 changes: 0 additions & 7 deletions src/go/rdctl/cmd/internalProcessWaitKill.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package cmd

import (
"fmt"
"runtime"

"github.com/rancher-sandbox/rancher-desktop/src/go/rdctl/pkg/process"
"github.com/spf13/cobra"
Expand All @@ -40,12 +39,6 @@ exit, and once it does, terminates all processes within the same process group.`
if err != nil {
return fmt.Errorf("failed to get process ID: %w", err)
}
if runtime.GOOS == "linux" {
// TODO: We can't use the process group on Linux, because Electron does
// not always create a new one. But for now still wait for the
// process to exit
return process.WaitForProcess(pid)
}
return process.KillProcessGroup(pid, true)
},
}
Expand Down
26 changes: 11 additions & 15 deletions src/go/rdctl/pkg/shutdown/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,17 @@ func terminateRancherDesktopFunc(appDir string) func(context.Context) error {
return func(ctx context.Context) error {
var errors *multierror.Error

// TODO: We can't use the process group on Linux, because Electron does
// not always create a new one.
if runtime.GOOS != "linux" {
errors = multierror.Append(errors, (func() error {
mainExe, err := p.GetMainExecutable(ctx)
if err != nil {
return err
}
pid, err := process.FindPidOfProcess(mainExe)
if err != nil {
return err
}
return process.KillProcessGroup(pid, false)
})())
}
errors = multierror.Append(errors, (func() error {
mainExe, err := p.GetMainExecutable(ctx)
if err != nil {
return err
}
pid, err := process.FindPidOfProcess(mainExe)
if err != nil {
return err
}
return process.KillProcessGroup(pid, false)
})())

errors = multierror.Append(errors, process.TerminateProcessInDirectory(appDir, true))

Expand Down

0 comments on commit ef273a3

Please sign in to comment.