The following program spawns /usr/bin/env and tries to close fileHandleForWriting for stdin.
This was run on Linux and it always crashes with: Fatal error: POSIX command failed with error: 9 – EBADF. On macOS works fine.
This affects Swift 5.1, but seems to be working on the latest master snapshot probably due to this PR.
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
let inputPipe = Pipe()
process.standardInput = inputPipe
swift File.swift && ./File
on macOS (via docker)
# assuming File.swift is in the working directory
docker run --privileged --rm -v "$PWD:$PWD" -w "$PWD" -it swift:5.1 bash -c 'swiftc File.swift && ./File'