1
Fork 0

Rollup merge of #97060 - bdbai:fix/uwphandle, r=ChrisDenton

Fix use of SetHandleInformation on UWP

The use of `SetHandleInformation` (introduced in #96441 to make `HANDLE` inheritable) breaks UWP builds because it is not available for UWP targets.

Proposed workaround: duplicate the `HANDLE` with `inherit = true` and immediately close the old one. Traditional Windows Desktop programs are not affected.

cc `@ChrisDenton`
This commit is contained in:
Dylan DPC 2022-05-15 18:41:27 +02:00 committed by GitHub
commit d56c59efdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -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(

View file

@ -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.