summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/main.go b/main.go
index ab20108..d58aaa6 100644
--- a/main.go
+++ b/main.go
@@ -257,13 +257,17 @@ func micCmd(source string) *exec.Cmd {
if source != "" {
args = append(args, "--device="+source)
}
- return exec.Command("parec", args...)
+ c := exec.Command("parec", args...)
+ c.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+ return c
}
func fileCmd(path string) *exec.Cmd {
- return exec.Command("ffmpeg", "-hide_banner", "-loglevel", "error",
+ c := exec.Command("ffmpeg", "-hide_banner", "-loglevel", "error",
"-re", "-i", path,
"-f", "s16le", "-acodec", "pcm_s16le", "-ac", "1", "-ar", "16000", "-")
+ c.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+ return c
}
func runASR(cmd *exec.Cmd, rec *sherpa.OnlineRecognizer, stream *sherpa.OnlineStream, pres *presenter) error {
@@ -388,6 +392,9 @@ func startRecorder(path, source string) (*exec.Cmd, error) {
}
cmd := exec.Command("ffmpeg", args...)
cmd.Stderr = os.Stderr
+ // Own process group: a terminal Ctrl+C signals the whole group, and ffmpeg
+ // receiving a second SIGINT while finalizing would truncate the mp4.
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
if err := cmd.Start(); err != nil {
return nil, err
}