-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Pipe Inheritance on Windows #2382
Conversation
@swift-ci please test linux |
Foundation/FileHandle.swift
Outdated
@@ -975,9 +975,15 @@ open class Pipe: NSObject { | |||
|
|||
public override init() { | |||
#if os(Windows) | |||
var saAttr = SECURITY_ATTRIBUTES() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can initialize this inline:
var saAttr: SECURITY_ATTRIBUTES = SECURITY_ATTRIBUTES(nLength: DWORD(MemoryLayout.size(of: saAttr)),
bInheritHandle: true, lpSecurityDescriptor: nil)
@@ -424,6 +427,7 @@ open class Process: NSObject { | |||
switch standardError { | |||
case let pipe as Pipe: | |||
siStartupInfo.hStdError = pipe.fileHandleForWriting.handle | |||
SetHandleInformation(pipe.fileHandleForReading.handle, DWORD(HANDLE_FLAG_INHERIT), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be restoring the attributes on the pipes?
e3b2e09
to
92f0453
Compare
Inlined and restored the pipe inheritance. |
@swift-ci please test linux |
- The Security Attributes should allow handle inheritance - The Startup info should indicate the child should use the passed in pipes for stdin/stdout/stderr - The write end of stdin and read end of stdout/stderr shouldn't be inherited by the child - Handles should be made inheritable if they are not
92f0453
to
42f9f6b
Compare
Changed: Files should also be set to be inheritable and reset. |
@swift-ci please test linux |
pipes for stdin/stdout/stderr
inherited by the child