-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Consider different way of inheriting handles in child processes on Windows #38227
Copy link
Copy link
Open
Labels
A-processArea: `std::process` and `std::env`Area: `std::process` and `std::env`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.O-windowsOperating system: WindowsOperating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-processArea: `std::process` and `std::env`Area: `std::process` and `std::env`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.O-windowsOperating system: WindowsOperating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Currently to avoid handles being inherited incorrectly by child processes due to race conditions, Rust wraps the whole blob of code in a mutex to synchronize it. However, it will still accidentally inherit any handles created elsewhere that are inheritable, can cause race conditions with people creating processes using libraries other than std, and isn't very efficient.
By switching from
STARTUPINFOtoSTARTUPINFOEX, we can pass a value forlpAttributeListand that attribute list can specify an explicit list of handles to inherit. For more information on this, see https://blogs.msdn.microsoft.com/oldnewthing/20111216-00/?p=8873Unfortunately this does require vista, so XP users will lose out.