summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/osproc.nim11
-rw-r--r--tests/osproc/tnoexe.nim18
2 files changed, 4 insertions, 25 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index c304ecca6..bd6bcde2b 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -1123,13 +1123,14 @@ elif not defined(useNimRtl):
       var error: cint
       let sizeRead = read(data.pErrorPipe[readIdx], addr error, sizeof(error))
       if sizeRead == sizeof(error):
-        raiseOSError(OSErrorCode(error),
+        raiseOSError(osLastError(),
                       "Could not find command: '" & $data.sysCommand & "'. OS error: " & $strerror(error))
 
       return pid
 
     {.push stacktrace: off, profiler: off.}
-    proc startProcessFail(data: ptr StartProcessData, error: cint = errno) =
+    proc startProcessFail(data: ptr StartProcessData) =
+      var error: cint = errno
       discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
       exitnow(1)
 
@@ -1166,11 +1167,7 @@ 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
-          var exe: string
-          try:
-            exe = findExe(data.sysCommand)
-          except OSError as e:
-            startProcessFail(data, e.errorCode)
+          let exe = findExe(data.sysCommand)
           discard execve(exe.cstring, data.sysArgs, data.sysEnv)
         else:
           # MacOSX doesn't have execvpe, so we need workaround.
diff --git a/tests/osproc/tnoexe.nim b/tests/osproc/tnoexe.nim
deleted file mode 100644
index 56edd0f87..000000000
--- a/tests/osproc/tnoexe.nim
+++ /dev/null
@@ -1,18 +0,0 @@
-discard """
-  output: '''true
-true'''
-"""
-
-import std/osproc
-
-const command = "lsaaa -lah"
-
-try:
-  let process = startProcess(command, options = {poUsePath})
-  discard process.waitForExit()
-except OSError as e:
-  echo e.errorCode != 0
-
-let process = startProcess(command, options = {poUsePath, poEvalCommand})
-let exitCode = process.waitForExit()
-echo exitCode != 0