Skip to content
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

Merged
merged 1 commit into from
Jul 5, 2019

Conversation

gmittert
Copy link
Contributor

  • 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

@gmittert
Copy link
Contributor Author

@swift-ci please test linux

@@ -975,9 +975,15 @@ open class Pipe: NSObject {

public override init() {
#if os(Windows)
var saAttr = SECURITY_ATTRIBUTES()
Copy link
Member

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)
Copy link
Member

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?

@gmittert gmittert force-pushed the ItWasMyGrandfathers branch from e3b2e09 to 92f0453 Compare June 26, 2019 22:12
@gmittert
Copy link
Contributor Author

Inlined and restored the pipe inheritance.

@gmittert
Copy link
Contributor Author

@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
@gmittert gmittert force-pushed the ItWasMyGrandfathers branch from 92f0453 to 42f9f6b Compare June 27, 2019 18:21
@gmittert
Copy link
Contributor Author

gmittert commented Jun 27, 2019

Changed: Files should also be set to be inheritable and reset.

@gmittert
Copy link
Contributor Author

@swift-ci please test linux

@millenomi millenomi merged commit 16df512 into swiftlang:master Jul 5, 2019
@gmittert gmittert deleted the ItWasMyGrandfathers branch July 22, 2019 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants