Browse Source

close custom commands with SIGQUIT instead of SIGINT (#495)

pull/509/head
aler9 5 years ago
parent
commit
d7f1c04711
  1. 2
      internal/core/rtsp_server_test.go
  2. 3
      internal/externalcmd/cmd_unix.go

2
internal/core/rtsp_server_test.go

@ -741,7 +741,7 @@ func TestRTSPServerFallback(t *testing.T) { @@ -741,7 +741,7 @@ func TestRTSPServerFallback(t *testing.T) {
func TestRTSPServerRunOnDemand(t *testing.T) {
doneFile := filepath.Join(os.TempDir(), "ondemand_done")
onDemandFile, err := writeTempFile([]byte(fmt.Sprintf(`#!/bin/sh
trap 'touch %s; [ -z "$(jobs -p)" ] || kill $(jobs -p)' INT
trap 'touch %s; [ -z "$(jobs -p)" ] || kill $(jobs -p)' QUIT
ffmpeg -hide_banner -loglevel error -re -i ../../testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH &
wait
`, doneFile)))

3
internal/externalcmd/cmd_unix.go

@ -5,6 +5,7 @@ package externalcmd @@ -5,6 +5,7 @@ package externalcmd
import (
"os"
"os/exec"
"syscall"
)
func (e *Cmd) runInner() bool {
@ -31,7 +32,7 @@ func (e *Cmd) runInner() bool { @@ -31,7 +32,7 @@ func (e *Cmd) runInner() bool {
select {
case <-e.terminate:
cmd.Process.Signal(os.Interrupt)
syscall.Kill(cmd.Process.Pid, syscall.SIGQUIT)
<-cmdDone
return false

Loading…
Cancel
Save