Implemented the exec builtin
Fixed readline and terminal interactions using stdin instead of /dev/tty
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user