diff --git a/main.go b/main.go index 7d46046..ad9ec21 100644 --- a/main.go +++ b/main.go @@ -124,8 +124,8 @@ func main() { ex := executor.NewExecutor(executor.ExecutorArgs{ Logger: logger, - Command: func(context.Context) *exec.Cmd { - cmd := exec.Command(execCmd, execArgs...) + Command: func(ctx context.Context) *exec.Cmd { + cmd := exec.CommandContext(ctx, execCmd, execArgs...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin diff --git a/pkg/executor/exec.go b/pkg/executor/exec.go index 95eac52..a129eaa 100644 --- a/pkg/executor/exec.go +++ b/pkg/executor/exec.go @@ -27,7 +27,7 @@ type ExecutorArgs struct { func NewExecutor(args ExecutorArgs) *Executor { done := make(chan os.Signal, 1) - signal.Notify(done, syscall.SIGTERM) + signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) if args.Logger == nil { args.Logger = slog.Default() @@ -51,8 +51,6 @@ func (ex *Executor) Exec() error { ex.mu.Unlock() }() - ex.logger.Debug("[exec] starting process") - ctx, cf := context.WithCancel(context.TODO()) defer cf() @@ -82,6 +80,7 @@ func (ex *Executor) Exec() error { } }() + ex.logger.Debug("[exec:post] process running") if err := cmd.Wait(); err != nil { if strings.HasPrefix(err.Error(), "signal:") { ex.logger.Debug("wait terminated, received", "signal", err.Error())