diff options
author | 握猫猫 <164346864@qq.com> | 2024-08-21 17:44:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 11:44:53 +0200 |
commit | 12b90d7c07c97772c833a80a84aa67f468ca8ac8 (patch) | |
tree | 6e84953f10e7d92725a5cb84869294542d188288 /lib | |
parent | e38cbd3c846a8e95bed0d709e4d61cc1ad5279b2 (diff) | |
download | Nim-12b90d7c07c97772c833a80a84aa67f468ca8ac8.tar.gz |
Fixed an issue where `errorCode` was always 0 when `startProcess` did… (#23992)
…n't use the `poEvalCommand` flag https://forum.nim-lang.org/t/12310 Added a test case, tested on my fedora system.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/osproc.nim | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index bd6bcde2b..c304ecca6 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -1123,14 +1123,13 @@ elif not defined(useNimRtl): var error: cint let sizeRead = read(data.pErrorPipe[readIdx], addr error, sizeof(error)) if sizeRead == sizeof(error): - raiseOSError(osLastError(), + raiseOSError(OSErrorCode(error), "Could not find command: '" & $data.sysCommand & "'. OS error: " & $strerror(error)) return pid {.push stacktrace: off, profiler: off.} - proc startProcessFail(data: ptr StartProcessData) = - var error: cint = errno + proc startProcessFail(data: ptr StartProcessData, error: cint = errno) = discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error)) exitnow(1) @@ -1167,7 +1166,11 @@ elif not defined(useNimRtl): if (poUsePath in data.options): when defined(uClibc) or defined(linux) or defined(haiku): # uClibc environment (OpenWrt included) doesn't have the full execvpe - let exe = findExe(data.sysCommand) + var exe: string + try: + exe = findExe(data.sysCommand) + except OSError as e: + startProcessFail(data, e.errorCode) discard execve(exe.cstring, data.sysArgs, data.sysEnv) else: # MacOSX doesn't have execvpe, so we need workaround. |