Skip to content

Commit a239222

Browse files
authored
Fix posix_spawn() error handling. (#855)
`posix_spawn()` does not (portably) set `errno`. Instead, it returns its error code. Fix our call. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 4be1dfe commit a239222

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/Testing/ExitTests/SpawnProcess.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ func spawnExecutable(
175175
}
176176

177177
var pid = pid_t()
178-
guard 0 == posix_spawn(&pid, executablePath, fileActions, attrs, argv, environ) else {
179-
throw CError(rawValue: swt_errno())
178+
let processSpawned = posix_spawn(&pid, executablePath, fileActions, attrs, argv, environ)
179+
guard 0 == processSpawned else {
180+
throw CError(rawValue: processSpawned)
180181
}
181182
return pid
182183
}

0 commit comments

Comments
 (0)