streamd v0.2.3: fix NRE Spectre crash under daemon (Linux PTY)
All checks were successful
release / build-and-upload (push) Successful in 6m56s
All checks were successful
release / build-and-upload (push) Successful in 6m56s
Wrap N_m3u8DL-RE with util-linux script so Spectre gets a real TTY; drop subtitles; pin COLUMNS/LINES; kill process group on stop. Fixes immediate 'downloader exited before any media arrived' on serve start.
This commit is contained in:
parent
a091922efa
commit
5b6f38c9cf
5 changed files with 235 additions and 32 deletions
|
|
@ -3,8 +3,10 @@
|
|||
package supervisor
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
|
|
@ -15,6 +17,29 @@ func hideWindow(cmd *exec.Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
func killProcessTree(cmd *exec.Cmd) error {
|
||||
if cmd == nil || cmd.Process == nil {
|
||||
return nil
|
||||
}
|
||||
pid := cmd.Process.Pid
|
||||
return exec.Command("taskkill", "/T", "/F", "/PID", strconv.Itoa(pid)).Run()
|
||||
}
|
||||
|
||||
// startNRELogged attaches logFile as Stdout/Stderr. Windows CREATE_NO_WINDOW
|
||||
// avoids the Spectre pipe-width crash that hits Linux daemons.
|
||||
func startNRELogged(cmd *exec.Cmd, logFile *os.File) (io.Closer, bool, error) {
|
||||
cmd.Stdout = logFile
|
||||
cmd.Stderr = logFile
|
||||
if err := cmd.Start(); err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
return nopCloser{}, true, nil
|
||||
}
|
||||
|
||||
type nopCloser struct{}
|
||||
|
||||
func (nopCloser) Close() error { return nil }
|
||||
|
||||
func processDead(pid int) bool {
|
||||
p, err := os.FindProcess(pid)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue