diff --git a/internal/staticsources/rpicamera/camera_arm_.go b/internal/staticsources/rpicamera/camera_arm_.go index 9c33c017..7c7b90a2 100644 --- a/internal/staticsources/rpicamera/camera_arm_.go +++ b/internal/staticsources/rpicamera/camera_arm_.go @@ -231,6 +231,12 @@ func (c *camera) initialize() error { c.cmd.Env = env c.cmd.Dir = dumpPath + // prevent the subprocess from receiving signals (in particular SIGINT and SIGTERM) + // from the parent process. + c.cmd.SysProcAttr = &syscall.SysProcAttr{ + Setpgid: true, + } + err = c.cmd.Start() if err != nil { c.pipeOut.close() @@ -282,24 +288,25 @@ func (c *camera) runInner() error { return err case err := <-readDone: - c.pipeIn.close() - c.pipeOut.write([]byte{'e'}) - c.pipeOut.close() <-cmdDone + c.pipeIn.close() + c.pipeOut.close() + return err case <-c.terminate: - c.pipeIn.close() - <-readDone - c.pipeOut.write([]byte{'e'}) - c.pipeOut.close() <-cmdDone + c.pipeOut.close() + c.pipeIn.close() + + <-readDone + return fmt.Errorf("terminated") } }