about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbdbai <bdbaiapp@163.com>2022-05-15 21:15:45 +0800
committerbdbai <bdbaiapp@163.com>2022-05-15 21:15:45 +0800
commit4f637ee30ba1ec9ab15c8b5d12e80e8ae810a811 (patch)
tree90cf41579ed2657fa5f3b65653d3c3262e6d408f
parente1ec3260d79497080ca86540562d410ba67d2a95 (diff)
downloadrust-4f637ee30ba1ec9ab15c8b5d12e80e8ae810a811.tar.gz
rust-4f637ee30ba1ec9ab15c8b5d12e80e8ae810a811.zip
fix use of SetHandleInformation on UWP
-rw-r--r--library/std/src/os/windows/io/handle.rs1
-rw-r--r--library/std/src/os/windows/io/socket.rs1
-rw-r--r--library/std/src/sys/windows/handle.rs1
-rw-r--r--library/std/src/sys/windows/pipe.rs13
4 files changed, 15 insertions, 1 deletions
diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs
index f27970eaaf1..0ecac6b4475 100644
--- a/library/std/src/os/windows/io/handle.rs
+++ b/library/std/src/os/windows/io/handle.rs
@@ -206,6 +206,7 @@ impl OwnedHandle {
     }
 
     /// Allow child processes to inherit the handle.
+    #[cfg(not(target_vendor = "uwp"))]
     pub(crate) fn set_inheritable(&self) -> io::Result<()> {
         cvt(unsafe {
             c::SetHandleInformation(
diff --git a/library/std/src/os/windows/io/socket.rs b/library/std/src/os/windows/io/socket.rs
index c14a1d6192f..7231fe7d1b6 100644
--- a/library/std/src/os/windows/io/socket.rs
+++ b/library/std/src/os/windows/io/socket.rs
@@ -10,6 +10,7 @@ use crate::mem;
 use crate::mem::forget;
 use crate::sys;
 use crate::sys::c;
+#[cfg(not(target_vendor = "uwp"))]
 use crate::sys::cvt;
 
 /// A borrowed socket.
diff --git a/library/std/src/sys/windows/handle.rs b/library/std/src/sys/windows/handle.rs
index 3b609825a79..c319cb28630 100644
--- a/library/std/src/sys/windows/handle.rs
+++ b/library/std/src/sys/windows/handle.rs
@@ -221,6 +221,7 @@ impl Handle {
         Ok(Self(self.0.duplicate(access, inherit, options)?))
     }
 
+    #[cfg(not(target_vendor = "uwp"))]
     pub(crate) fn set_inheritable(&self) -> io::Result<()> {
         self.0.set_inheritable()
     }
diff --git a/library/std/src/sys/windows/pipe.rs b/library/std/src/sys/windows/pipe.rs
index 928bf2439c3..2c586f1abe4 100644
--- a/library/std/src/sys/windows/pipe.rs
+++ b/library/std/src/sys/windows/pipe.rs
@@ -57,10 +57,21 @@ impl Pipes {
             } else {
                 let (ours, theirs) = if ours_readable { (read, write) } else { (write, read) };
                 let ours = Handle::from_raw_handle(ours);
+                #[cfg(not(target_vendor = "uwp"))]
                 let theirs = Handle::from_raw_handle(theirs);
+                #[cfg(target_vendor = "uwp")]
+                let mut theirs = Handle::from_raw_handle(theirs);
 
                 if their_handle_inheritable {
-                    theirs.set_inheritable()?;
+                    #[cfg(not(target_vendor = "uwp"))]
+                    {
+                        theirs.set_inheritable()?;
+                    }
+
+                    #[cfg(target_vendor = "uwp")]
+                    {
+                        theirs = theirs.duplicate(0, true, c::DUPLICATE_SAME_ACCESS)?;
+                    }
                 }
 
                 Ok(Pipes { ours: AnonPipe::Sync(ours), theirs: AnonPipe::Sync(theirs) })