     #endif
 
     open func run() throws {
+
+        func _throwIfPosixError(_ posixErrno: Int32) throws {
+            if posixErrno != 0 {
+                // When this is called, self.executableURL is already known to be non-nil
+                let userInfo: [String: Any] = [ NSURLErrorKey: self.executableURL! ]
+                throw NSError(domain: NSPOSIXErrorDomain, code: Int(posixErrno), userInfo: userInfo)
+            }
+        }
+
         self.processLaunchedCondition.lock()
         defer {
             self.processLaunchedCondition.broadcast()

                  fd != taskSocketPair[1] else {
                    continue // Do not double-close descriptors, or close those pertaining to Pipes or FileHandles we want inherited.
            }
            posix(_CFPosixSpawnFileActionsAddClose(fileActions, fd))
        }
        #endif


        }

        for (new, old) in adddup2 {
            try _throwIfPosixError(_CFPosixSpawnFileActionsAddDup2(fileActions, old, new))
        }
        for fd in addclose.filter({ $0 >= 0 }) {
            try _throwIfPosixError(_CFPosixSpawnFileActionsAddClose(fileActions, fd))
        }

        #if canImport(Darwin)
        var spawnAttrs: posix_spawnattr_t? = nil
        try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
        try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_CLOEXEC_DEFAULT)))
        #else
        for fd in 3 ... findMaximumOpenFD() {
            guard adddup2[fd] == nil &&
