feat(process): validate KillGroup requires Detach
This commit is contained in:
parent
87bebd7fa6
commit
f70e301631
2 changed files with 16 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue