Implemented the exec builtin

Fixed readline and terminal interactions using stdin instead of /dev/tty
This commit is contained in:
2026-02-20 12:17:48 -05:00
parent 2184b9b361
commit 129390c2da
16 changed files with 384 additions and 41 deletions

View File

@@ -39,6 +39,9 @@ pub enum IoMode {
buf: String,
pipe: Arc<OwnedFd>,
},
Close {
tgt_fd: RawFd,
}
}
impl IoMode {
@@ -152,6 +155,21 @@ impl<R: Read> IoBuf<R> {
}
pub struct RedirGuard(IoFrame);
impl RedirGuard {
pub fn persist(mut self) {
if let Some(saved) = self.0.saved_io.take() {
close(saved.0).ok();
close(saved.1).ok();
close(saved.2).ok();
}
// the guard is dropped here
// but since we took the saved fds
// the drop does not restore them
}
}
impl Drop for RedirGuard {
fn drop(&mut self) {
self.0.restore().ok();