summary refs log tree commit diff stats
path: root/lib/pure/osproc.nim
diff options
context:
space:
mode:
authorRuslan Mustakov <endragor@users.noreply.github.com>2017-05-18 03:40:55 +0700
committerAndreas Rumpf <rumpf_a@web.de>2017-05-17 22:40:55 +0200
commit0a76387ba4186a7d316e40c9abbe5d4b30f6c3cb (patch)
tree5d0b80f1854107b5040c20acfb203ab27f5b580d /lib/pure/osproc.nim
parent8f67b90997d1c0416c4991ecec666a63339103c2 (diff)
downloadNim-0a76387ba4186a7d316e40c9abbe5d4b30f6c3cb.tar.gz
Fix posix_spawn error handling (#5826)
posix_spawn doesn't set errno - it returns the error code.
Diffstat (limited to 'lib/pure/osproc.nim')
-rw-r--r--lib/pure/osproc.nim5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index c94a65a63..23c8546c4 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -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: