From 6beca95e101d3f362c0d54647ee2423f2ec8e75d Mon Sep 17 00:00:00 2001 From: Cheuk <90270663+cheukt@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:13:59 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Benjamin Rewis <32186188+benjirewis@users.noreply.github.com> --- pexec/managed_process.go | 3 ++- pexec/managed_process_unix.go | 2 +- pexec/managed_process_windows.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pexec/managed_process.go b/pexec/managed_process.go index e3081006..7f03fecf 100644 --- a/pexec/managed_process.go +++ b/pexec/managed_process.go @@ -32,7 +32,7 @@ type ManagedProcess interface { // there's any system level issue stopping the process. Stop() error - // Kill will attempt to kill the process group and not wait for completion. Only use this if + // KillGroup will attempt to kill the process group and not wait for completion. Only use this if // comfortable with leaking resources (in cases where exiting the program as quickly as possible is desired). KillGroup() @@ -437,6 +437,7 @@ func (p *managedProcess) Stop() error { return errors.Errorf("non-successful exit code: %d", p.cmd.ProcessState.ExitCode()) } +// KillGroup kills the process group. func (p *managedProcess) KillGroup() { // Minimally hold a lock here so that we can signal the // management goroutine to stop. We will attempt to kill the diff --git a/pexec/managed_process_unix.go b/pexec/managed_process_unix.go index e2f81b54..a5be4317 100644 --- a/pexec/managed_process_unix.go +++ b/pexec/managed_process_unix.go @@ -127,7 +127,7 @@ func (p *managedProcess) kill() (bool, error) { return forceKilled, nil } -// forceKill kills everything in the process group. This will not wait for completion and may result the +// forceKillGroup kills everything in the process group. This will not wait for completion and may result the // kill becoming a zombie process. func (p *managedProcess) forceKillGroup() error { pgidStr := strconv.Itoa(-p.cmd.Process.Pid) diff --git a/pexec/managed_process_windows.go b/pexec/managed_process_windows.go index 63a18983..df758860 100644 --- a/pexec/managed_process_windows.go +++ b/pexec/managed_process_windows.go @@ -106,7 +106,7 @@ func (p *managedProcess) kill() (bool, error) { return forceKilled, nil } -// forceKill kills everything in the process tree. This will not wait for completion and may result in a zombie process. +// forceKillGroup kills everything in the process tree. This will not wait for completion and may result in a zombie process. func (p *managedProcess) forceKillGroup() error { pidStr := strconv.Itoa(p.cmd.Process.Pid) p.logger.Infof("force killing entire process tree %d", p.cmd.Process.Pid)