summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorMichał Zieliński <michal@zielinscy.org.pl>2014-02-23 23:08:48 +0100
committerMichał Zieliński <michal@zielinscy.org.pl>2014-02-24 17:01:00 +0100
commit30a3098095e2d04939cc8f1074507343f65a58d4 (patch)
tree93c80a6246be23941d2e3471375f3d60d582bbb9 /lib
parent00b69192f2fc4d5b0546d5b45a32383b2536275d (diff)
downloadNim-30a3098095e2d04939cc8f1074507343f65a58d4.tar.gz
osproc: MacOSX workaround for lack of execvpe
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/osproc.nim11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 79a4de04b..4e17d3e02 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -779,6 +779,9 @@ elif not defined(useNimRtl):
     discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
     exitnow(1)
 
+  when defined(macosx):
+    var environ {.importc.}: cstringArray
+
   proc startProcessAfterFork(data: ptr TStartProcessData) =
     # Warning: no GC here!
     # Or anythink that touches global structures - all called nimrod procs
@@ -806,7 +809,13 @@ elif not defined(useNimRtl):
     discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
 
     if data.optionPoUsePath:
-      discard execvpe(data.sysCommand, data.sysArgs, data.sysEnv)
+      when defined(macosx):
+        # MacOSX doesn't have execvpe, so we need workaround.
+        # On MacOSX we can arrive here only from fork, so this is safe:
+        environ = data.sysEnv
+        discard execvp(data.sysCommand, data.sysArgs)
+      else:
+        discard execvpe(data.sysCommand, data.sysArgs, data.sysEnv)
     else:
       discard execve(data.sysCommand, data.sysArgs, data.sysEnv)