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

[SR-625] NSTask on ubuntu dont redirect stdout to NSPipe #4464

Closed
swift-ci opened this issue Jan 27, 2016 · 3 comments
Closed

[SR-625] NSTask on ubuntu dont redirect stdout to NSPipe #4464

swift-ci opened this issue Jan 27, 2016 · 3 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-625
Radar None
Original Reporter demom (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 3
Component/s Foundation
Labels Bug
Assignee aa (JIRA)
Priority Medium

md5: fedd9dcafb87ff1567e4f6551157711b

Issue Description:

When implementing the following code, the execution hangs on Ubuntu, but not on OS X.

After digging through some code, I don't think NSTask actually redirects stdout to pipe, causing readDataToEndOfFile() to hang.

func system(launchPath: String, arguments: String...) -> (status: Int32, output: String)
{
    let task = NSTask()
    task.launchPath = launchPath
    task.arguments = arguments

    let pipe = NSPipe()
    task.standardOutput = pipe
    task.launch()
    //task.waitUntilExit()  // Tested with and without this

    let data = pipe.fileHandleForReading.readDataToEndOfFile()
    let output = String(NSString(data: data, encoding: NSUTF8StringEncoding)!)
        
    return (task.terminationStatus, output)
}

https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSTask.swift

@swift-ci
Copy link
Contributor Author

Comment by Alexander Alemayhu (JIRA)

Also seen this on Ubuntu (14.04.4 LTS), running `Swift version 3.0-dev (LLVM b361b0fc05, Clang 11493b0f62, Swift fc261045a5)`.

@Dante-Broggi
Copy link

Is this resolved, or no longer valid? If either, this should be closed.

@swift-ci
Copy link
Contributor Author

Comment by Alexander Alemayhu (JIRA)

I think this has been fixed. There was been several changes since this was reported and I could not reproduce it on Ubuntu 16.04.3 running `(swift-4.0.3-RELEASE)`.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants