mirror of
https://github.com/wez/wezterm.git
synced 2024-09-11 14:25:57 +03:00
add docs for as_stdio
This commit is contained in:
parent
143617155e
commit
ee9b5c7a68
@ -109,6 +109,14 @@ impl FileDescriptor {
|
|||||||
pub fn try_clone(&self) -> Fallible<Self> {
|
pub fn try_clone(&self) -> Fallible<Self> {
|
||||||
self.handle.try_clone().map(|handle| Self { handle })
|
self.handle.try_clone().map(|handle| Self { handle })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A convenience method for creating a `std::process::Stdio` object
|
||||||
|
/// to be used for eg: redirecting the stdio streams of a child
|
||||||
|
/// process. The `Stdio` is created using a duplicated handle so
|
||||||
|
/// that the source handle remains alive.
|
||||||
|
pub fn as_stdio(&self) -> Fallible<std::process::Stdio> {
|
||||||
|
self.as_stdio_impl()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pipes {
|
pub struct Pipes {
|
||||||
|
@ -161,7 +161,8 @@ impl FileDescriptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_stdio(&self) -> Fallible<std::process::Stdio> {
|
#[inline]
|
||||||
|
pub(crate) fn as_stdio_impl(&self) -> Fallible<std::process::Stdio> {
|
||||||
let duped = OwnedHandle::dup(self)?;
|
let duped = OwnedHandle::dup(self)?;
|
||||||
let fd = duped.into_raw_fd();
|
let fd = duped.into_raw_fd();
|
||||||
let stdio = unsafe { std::process::Stdio::from_raw_fd(fd) };
|
let stdio = unsafe { std::process::Stdio::from_raw_fd(fd) };
|
||||||
|
@ -97,7 +97,8 @@ impl IntoRawHandle for OwnedHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FileDescriptor {
|
impl FileDescriptor {
|
||||||
pub fn as_stdio(&self) -> Fallible<std::process::Stdio> {
|
#[inline]
|
||||||
|
pub(crate) fn as_stdio_impl(&self) -> Fallible<std::process::Stdio> {
|
||||||
let duped = self.handle.try_clone()?;
|
let duped = self.handle.try_clone()?;
|
||||||
let handle = duped.into_raw_handle();
|
let handle = duped.into_raw_handle();
|
||||||
let stdio = unsafe { std::process::Stdio::from_raw_handle(handle) };
|
let stdio = unsafe { std::process::Stdio::from_raw_handle(handle) };
|
||||||
|
Loading…
Reference in New Issue
Block a user