fix: fall through to self-launch when peer forward fails

After PipeClient::connect succeeds, write_all(...).ok() ignored failure
and unconditionally exit(0). If the peer instance died between connect
and write the user command was silently dropped and no shell launched.

Treat a failed write as a reason to launch this process: only exit when
the command was successfully forwarded (write + flush). Otherwise log
the failure and fall through to the regular launch path.

Closes #45
This commit is contained in:
Claude 2026-05-10 12:30:43 +00:00
parent bbbe882faf
commit da72eb70a1
No known key found for this signature in database

View file

@ -88,8 +88,15 @@ fn main() {
commands_path.push_str(&username());
let socket_path = Path::new(&commands_path);
if let Ok(mut stream) = PipeClient::connect(socket_path) {
stream.write_all(command.as_bytes()).ok();
exit(0);
let forwarded = stream
.write_all(command.as_bytes())
.and_then(|_| stream.flush())
.is_ok();
drop(stream);
if forwarded {
exit(0);
}
eprintln!("Failed to forward command to existing Stremio instance; launching new instance");
}
// END IPC