Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jsturtevant/38053ea489c2a2de2a904d3910df8e03 to your computer and use it in GitHub Desktop.
Save jsturtevant/38053ea489c2a2de2a904d3910df8e03 to your computer and use it in GitHub Desktop.
convert libc handle to rust OwnedHandle
crates/containerd-shim-wasm/src/sys/windows/stdio.rs
```
pub fn as_owned(&self)-> Option<OwnedHandle> {
if let Some(fd) = self.as_raw_fd() {
return Some(unsafe {OwnedHandle::from_raw_handle(get_osfhandle(fd) as _)});
}
None
}
```
crates/containerd-shim-wasm/src/sandbox/stdio.rs
```
#[cfg(windows)]
pub fn as_owned(self) -> Option<OwnedHandle> {
self.0.as_owned()
}
```
Pass to the command:
```
let mut cmd = Command::new("containerd-wasmtime-windows");
cmd.current_dir(self.bundle.as_path())
.arg("--address").arg(self.address.clone())
.arg("--namespace").arg(self.namespace.clone())
.stdout(self.stio.take().stdout.as_owned());
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment