From f70e301631ace93e77523b876f13d416e7035162 Mon Sep 17 00:00:00 2001 From: Virgil Date: Fri, 3 Apr 2026 23:34:16 +0000 Subject: [PATCH] feat(process): validate KillGroup requires Detach --- service.go | 4 ++++ service_test.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/service.go b/service.go index f4fd18f..b9fbf1c 100644 --- a/service.go +++ b/service.go @@ -104,6 +104,10 @@ func (s *Service) Start(ctx context.Context, command string, args ...string) (*P func (s *Service) StartWithOptions(ctx context.Context, opts RunOptions) (*Process, error) { id := fmt.Sprintf("proc-%d", s.idCounter.Add(1)) + if opts.KillGroup && !opts.Detach { + return nil, coreerr.E("Service.StartWithOptions", "KillGroup requires Detach", nil) + } + // Detached processes use Background context so they survive parent death parentCtx := ctx if opts.Detach { diff --git a/service_test.go b/service_test.go index 7d3a64e..7c6b640 100644 --- a/service_test.go +++ b/service_test.go @@ -150,6 +150,18 @@ func TestService_Start(t *testing.T) { t.Fatal("detached process should have completed") } }) + + t.Run("kill group requires detach", func(t *testing.T) { + svc, _ := newTestService(t) + + _, err := svc.StartWithOptions(context.Background(), RunOptions{ + Command: "sleep", + Args: []string{"1"}, + KillGroup: true, + }) + require.Error(t, err) + assert.Contains(t, err.Error(), "KillGroup requires Detach") + }) } func TestService_Run(t *testing.T) {