mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
Fix posix_spawn error handling (#5826)
posix_spawn doesn't set errno - it returns the error code.
This commit is contained in:
committed by
Andreas Rumpf
parent
8f67b90997
commit
0a76387ba4
@@ -863,18 +863,15 @@ elif not defined(useNimRtl):
|
||||
if data.workingDir.len > 0:
|
||||
setCurrentDir($data.workingDir)
|
||||
var pid: Pid
|
||||
var err: OSErrorCode
|
||||
|
||||
if data.optionPoUsePath:
|
||||
res = posix_spawnp(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
|
||||
if res != 0'i32: err = osLastError()
|
||||
else:
|
||||
res = posix_spawn(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv)
|
||||
if res != 0'i32: err = osLastError()
|
||||
|
||||
discard posix_spawn_file_actions_destroy(fops)
|
||||
discard posix_spawnattr_destroy(attr)
|
||||
if res != 0'i32: raiseOSError(err)
|
||||
if res != 0'i32: raiseOSError(OSErrorCode(res))
|
||||
|
||||
return pid
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user