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
|
|
@ -64,6 +64,34 @@ func OpenWithBanner(path string, maxBytes int64, generations int, what string) (
|
|||
return w, nil
|
||||
}
|
||||
|
||||
// OpenCmdLog prepares a rotating append log and returns the live *os.File for
|
||||
// exec.Cmd Stdout/Stderr. Go only inherits a real FD for *os.File; any other
|
||||
// io.Writer becomes a pipe, and N_m3u8DL-RE's Spectre progress UI crashes on
|
||||
// pipe-backed consoles (ArgumentException in LiveRenderable.RemoveRange).
|
||||
//
|
||||
// The caller owns the file and must Close it. Mid-run size rotation is skipped
|
||||
// (rotation still happens at open when the prior file is already over the cap).
|
||||
func OpenCmdLog(path string, maxBytes int64, generations int, what string) (*os.File, error) {
|
||||
w, err := OpenWithBanner(path, maxBytes, generations, what)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return w.DetachFile()
|
||||
}
|
||||
|
||||
// DetachFile transfers ownership of the underlying *os.File to the caller.
|
||||
// The Writer becomes inert; do not Write or Close it afterward.
|
||||
func (w *Writer) DetachFile() (*os.File, error) {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if w.f == nil {
|
||||
return nil, os.ErrClosed
|
||||
}
|
||||
f := w.f
|
||||
w.f = nil
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func (w *Writer) reopen() error {
|
||||
f, err := os.OpenFile(w.path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue