-
Notifications
You must be signed in to change notification settings - Fork 23
There should be dedicated API to collect merged stdout+stderr as a single stream (stdout and stderr going to the same underlying fd) #59
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
Comments
Can't you use the |
How could that possibly produce the same result w.r.t. ordering? |
Ditto to @FranzBusch 's answer. The current design uses |
@jakepetroules is right that the ordering with |
Actually, this approach works with the current API surface: let (readEnd, writeEnd) = try FileDescriptor.pipe()
return try await readEnd.closeAfter {
// Direct both stdout and stderr to the same fd. Only set `closeAfterSpawningProcess` on one of the outputs so it isn't double-closed (similarly avoid using closeAfter for the same reason).
let result = try await Subprocess.run(
.path(FilePath(url.filePath.str)),
arguments: .init(arguments),
environment: environment.map { .custom(.init($0)) } ?? .inherit,
workingDirectory: (currentDirectoryURL?.filePath.str).map { FilePath($0) } ?? nil,
output: .fileDescriptor(writeEnd, closeAfterSpawningProcess: true),
error: .fileDescriptor(writeEnd, closeAfterSpawningProcess: false))
// read from `readEnd` here...
} |
Actually I'll leave this open to allow consideration of a higher level API for this (which I think would be a reasonable addition). That said, there is a workaround for now, it's just a little lower level than I'd prefer, especially since the client has to provide their own mechanism to read from the fd in an async-friendly manner. |
The API only allows collecting stdout and stderr separately, not as a single stream. This makes it impossible to build something like a Terminal app where the stdout+stderr of a process should be interleaved in the order of emission.
The text was updated successfully, but these errors were encountered: