mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +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}`);
|
console.log(`Monitoring stdin pipe: ${stdinPath}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Open the FIFO for reading (non-blocking)
|
// Open FIFO for both read and write (like tty-fwd) to keep it open
|
||||||
const stdinStream = fs.createReadStream(stdinPath, {
|
const stdinFd = fs.openSync(stdinPath, 'r+'); // r+ = read/write
|
||||||
encoding: 'utf8',
|
const stdinStream = fs.createReadStream('', { fd: stdinFd, encoding: 'utf8' });
|
||||||
flags: 'r',
|
|
||||||
});
|
|
||||||
|
|
||||||
stdinStream.on('data', (data: string) => {
|
stdinStream.on('data', (data: string) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -228,9 +226,18 @@ async function main() {
|
||||||
console.warn('Stdin FIFO stream error:', error);
|
console.warn('Stdin FIFO stream error:', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
stdinStream.on('end', () => {
|
||||||
|
console.log('Stdin FIFO stream ended');
|
||||||
|
});
|
||||||
|
|
||||||
// Clean up on exit
|
// Clean up on exit
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
stdinStream.destroy();
|
try {
|
||||||
|
stdinStream.destroy();
|
||||||
|
fs.closeSync(stdinFd);
|
||||||
|
} catch (_e) {
|
||||||
|
// Ignore cleanup errors
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to set up stdin FIFO monitoring:', error);
|
console.warn('Failed to set up stdin FIFO monitoring:', error);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue