summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-05-22 21:23:43 +0200
committerAraq <rumpf_a@web.de>2011-05-22 21:23:43 +0200
commitd8c6e0ed924e844e9671c61434efc3f0e1269e73 (patch)
treed41e576ae9705344701caad9b024fb0b22c8108c /lib
parentea7425b6e2c082ee108f94f5fce886b4e21f9938 (diff)
downloadNim-d8c6e0ed924e844e9671c61434efc3f0e1269e73.tar.gz
bugfix stderr osproc
Diffstat (limited to 'lib')
-rwxr-xr-xlib/pure/osproc.nim11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index ef7c7f3ba..7981720d9 100755
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -475,8 +475,7 @@ elif not defined(useNimRtl):
        pipe(p_stderr) != 0'i32:
       OSError("failed to create a pipe")
     var Pid = fork()
-    if Pid < 0:
-      OSError("failed to fork process")
+    if Pid < 0: OSError("failed to fork process")
 
     if pid == 0:
       ## child process:
@@ -484,15 +483,13 @@ elif not defined(useNimRtl):
       if dup2(p_stdin[readIdx], readIdx) < 0: OSError()
       discard close(p_stdout[readIdx])
       if dup2(p_stdout[writeIdx], writeIdx) < 0: OSError()
+      discard close(p_stderr[readIdx])
       if poStdErrToStdOut in options:
-        discard close(p_stderr[readIdx])
         if dup2(p_stdout[writeIdx], 2) < 0: OSError()
       else:
-        discard close(p_stderr[readIdx])
         if dup2(p_stderr[writeIdx], 2) < 0: OSError()
 
-      if workingDir.len > 0:
-        os.setCurrentDir(workingDir)
+      if workingDir.len > 0: os.setCurrentDir(workingDir)
       if poUseShell notin options:
         var a = toCStringArray([extractFilename(command)], args)
         if env == nil:
@@ -519,7 +516,7 @@ elif not defined(useNimRtl):
       result.errorHandle = result.outputHandle
     else:
       result.errorHandle = p_stderr[readIdx]
-      discard close(p_stderr[writeIdx])
+    discard close(p_stderr[writeIdx])
     discard close(p_stdin[readIdx])
     discard close(p_stdout[writeIdx])