swift-foundation
swift-foundation copied to clipboard
Process / NSTask
We need to reimagine what Process should look like in Swift. Most likely we will introduce a new type.
rdar://118127512
FWIW, I did some work on launching a Process in Swift. It’s probably not what I’d want in Foundation as-is, but it can give some ideas.
https://github.com/xcode-actions/XcodeTools/blob/main/Sources/XcodeTools/Process/ProcessInvocation.swift
On the top of my head, my main pain points were (unordered):
- No possibilities of sending file descriptors to the child;
- No easy streaming of process output (bonus, w/
fddifferentiation); - PGID is different on child process (and there is no option to change that);
Processdoes not search for the executable inPATHfor non-absolute paths.
There are other problems with the current API of course, but they are more obvious.
I think that one thing that I would like to bring up while this is early in the process - Windows likes to throw a stupid wrench into this :(. The environment control block should be case insensitive. This is particularly important for Path (vs PATH) and any possible case variant which should be treated equivalently.
Pitch is up: https://github.com/apple/swift-foundation/pull/397