term: Fix editor closing `stderr` stream
This commit is contained in:
parent
94cd7658b1
commit
0c41de1433
|
|
@ -2141,6 +2141,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"inquire",
|
||||
"is-terminal",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"pretty_assertions",
|
||||
"tempfile",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ anyhow = { version = "1" }
|
|||
anstyle-query = { version = "1.0.0" }
|
||||
is-terminal = { version = "0.4.4" }
|
||||
inquire = { version = "0.6", default-features = false, features = ["termion", "editor"] }
|
||||
libc = { version = "0.2" }
|
||||
once_cell = { version = "1.13" }
|
||||
termion = { version = "2" }
|
||||
unicode-width = { version = "0.1.10", default-features = false }
|
||||
|
|
|
|||
|
|
@ -67,8 +67,17 @@ impl Editor {
|
|||
)
|
||||
);
|
||||
};
|
||||
|
||||
// We duplicate the stderr file descriptor to pass it to the child process, otherwise, if
|
||||
// we simply pass the `RawFd` of our stderr, `Command` will close our stderr when the
|
||||
// child exits.
|
||||
let stderr = io::stderr().as_raw_fd();
|
||||
let stderr = unsafe { libc::dup(stderr) };
|
||||
|
||||
process::Command::new(cmd)
|
||||
.stdout(unsafe { process::Stdio::from_raw_fd(io::stderr().as_raw_fd()) })
|
||||
.stdout(unsafe { process::Stdio::from_raw_fd(stderr) })
|
||||
.stderr(process::Stdio::inherit())
|
||||
.stdin(process::Stdio::inherit())
|
||||
.arg(&self.path)
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue