From a9214fd3f7ed0f4f3558e490a317aabfefbbb2a8 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Wed, 15 Jan 2025 10:59:23 -0800 Subject: [PATCH] if the process doesn't exist, error rather than segfaulting --- internal/ibazel/process_group/process_group_unix.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/ibazel/process_group/process_group_unix.go b/internal/ibazel/process_group/process_group_unix.go index 501c4b73..54f64ea1 100644 --- a/internal/ibazel/process_group/process_group_unix.go +++ b/internal/ibazel/process_group/process_group_unix.go @@ -12,11 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package process_group import ( + "fmt" "os/exec" "syscall" ) @@ -45,7 +47,10 @@ func (pg *unixProcessGroup) Signal(signum syscall.Signal) error { // Send the signal to the process PID which should propagate down to any // subprocesses in the PGID (Process Group ID). To send to the PGID, send the // signal to the negative of the process PID. - return syscall.Kill(-pg.root.Process.Pid, signum) + if pg.root.Process != nil { + return syscall.Kill(-pg.root.Process.Pid, signum) + } + return fmt.Errorf("root process not started") } func (pg *unixProcessGroup) Wait() error {