Isolate ffmpeg process group

This commit is contained in:
Thales Maciel 2026-02-06 18:55:13 -03:00
parent d124bfa24c
commit 49ef349d48
2 changed files with 5 additions and 1 deletions

View file

@ -7,6 +7,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"syscall"
"time"
)
@ -31,6 +32,8 @@ func (r Recorder) Start(ctx context.Context) (*exec.Cmd, *RecordResult, error) {
args = append(args, "-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le", wav)
cmd := exec.CommandContext(ctx, "ffmpeg", args...)
// Put ffmpeg in its own process group so Ctrl+C only targets the daemon.
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
if err := cmd.Start(); err != nil {
_ = os.RemoveAll(tmpdir)
return nil, nil, err