mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-24 14:47:39 +00:00
Fix FIFO stdin handling by opening for read+write like tty-fwd
- Open stdin FIFO with 'r+' mode to keep it open continuously
- Use fs.openSync + createReadStream for proper FIFO handling
- Prevent FIFO from closing when external writers disconnect
- Follow tty-fwd pattern of opening FIFO for both read and write
- Remove problematic spawn('cat') approach that was exiting
This should fix the issue where stdin FIFO closes after first input.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a2b0ba77da
commit
7a37f7a231
1 changed files with 13 additions and 6 deletions
|
|
@ -209,11 +209,9 @@ async function main() {
|
|||
console.log(`Monitoring stdin pipe: ${stdinPath}`);
|
||||
|
||||
try {
|
||||
// Open the FIFO for reading (non-blocking)
|
||||
const stdinStream = fs.createReadStream(stdinPath, {
|
||||
encoding: 'utf8',
|
||||
flags: 'r',
|
||||
});
|
||||
// Open FIFO for both read and write (like tty-fwd) to keep it open
|
||||
const stdinFd = fs.openSync(stdinPath, 'r+'); // r+ = read/write
|
||||
const stdinStream = fs.createReadStream('', { fd: stdinFd, encoding: 'utf8' });
|
||||
|
||||
stdinStream.on('data', (data: string) => {
|
||||
try {
|
||||
|
|
@ -228,9 +226,18 @@ async function main() {
|
|||
console.warn('Stdin FIFO stream error:', error);
|
||||
});
|
||||
|
||||
stdinStream.on('end', () => {
|
||||
console.log('Stdin FIFO stream ended');
|
||||
});
|
||||
|
||||
// Clean up on exit
|
||||
process.on('exit', () => {
|
||||
stdinStream.destroy();
|
||||
try {
|
||||
stdinStream.destroy();
|
||||
fs.closeSync(stdinFd);
|
||||
} catch (_e) {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Failed to set up stdin FIFO monitoring:', error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue