Skip to content

fix: allow --out to target FIFOs and char devices (e.g. /dev/stdout) - #796

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
trappedinspacetime:fix/out-stdout-pipe
Oct 5, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
trappedinspacetime:fix/out-stdout-pipe

Conversation

@trappedinspacetime

Copy link
Copy Markdown
Contributor

Problem

--out cannot target a pipe, FIFO, or character device such as
/dev/stdout. Piping TTS output directly into a player (e.g.
audiocpp_cli ... --out /dev/stdout | aplay -t wav -) silently
produces no audio on the reader side.

Root cause

write_wav_output() in app/workflow/file_sink.cpp always writes to
a sibling <path>.tmp file and then calls std::filesystem::rename(tmp, path)
to move it into place atomically. When path is a FIFO or a char
device, rename() unlinks that special file and replaces it with a
plain regular file instead of writing into it — so nothing ever
reaches whatever has the other end open (e.g. a reader blocked on
open() for a named pipe, or the process on the other end of a shell
pipe).

WavSink::write() / write_wav() itself is not the problem: it's a
single sequential pass with no seeking (the RIFF/data chunk sizes are
computed up front from the in-memory sample buffer, not patched in
after the fact), so writing straight to a special file is safe.

Fix

Detect when the target path is a FIFO, character device, or socket
(std::filesystem::status follows symlinks, so this also covers
/dev/stdout when it resolves to a pipe) and skip the temp-file +
rename step for those targets, writing directly instead. Regular
files keep the existing temp+rename behavior unchanged.

Build

@0xShug0
0xShug0 merged commit 54aa279 into 0xShug0:main Oct 5, 2026
6 checks passed
@0xShug0

0xShug0 commented Oct 5, 2026

Copy link
Copy Markdown
Owner

@trappedinspacetime Thanks! PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants