//! Windows asynchronous process handling. //! //! Like with Unix we don't actually have a way of registering a process with an //! IOCP object. As a result we similarly need another mechanism for getting a //! signal when a process has exited. For now this is implemented with the //! `RegisterWaitForSingleObject` function in the kernel32.dll. //! //! This strategy is the same that libuv takes and essentially just queues up a //! wait for the process in a kernel32-specific thread pool. Once the object is //! notified (e.g. the process exits) then we have a callback that basically //! just completes a `Oneshot`. //! //! The `poll_exit` implementation will attempt to wait for the process in a //! nonblocking fashion, but failing that it'll fire off a //! `RegisterWaitForSingleObject` and then wait on the other end of the oneshot //! from then on out.
use std::fmt; use std::fs::File as StdFile; use std::future::Future; use std::io; use std::os::windows::prelude::{AsRawHandle, IntoRawHandle, OwnedHandle, RawHandle}; use std::pin::Pin; use std::process::Stdio; use std::process::{Child as StdChild, Command as StdCommand, ExitStatus}; use std::sync::Arc; use std::task::{Context, Poll};
#[derive(Debug)] pub(crate) struct ChildStdio { // Used for accessing the raw handle, even if the io version is busy
raw: Arc<StdFile>, // For doing I/O operations asynchronously
io: Blocking<ArcFile>,
}
pub(super) fn stdio<T>(io: T) -> io::Result<ChildStdio> where
T: IntoRawHandle,
{ use std::os::windows::prelude::FromRawHandle;
let raw = Arc::new(unsafe { StdFile::from_raw_handle(io.into_raw_handle()) }); let io = Blocking::new(ArcFile(raw.clone()));
Ok(ChildStdio { raw, io })
}
fn convert_to_file(child_stdio: ChildStdio) -> io::Result<StdFile> { let ChildStdio { raw, io } = child_stdio;
drop(io); // Try to drop the Arc count here
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.