parent
47c7fd037e
commit
bacf08e65d
2 changed files with 36 additions and 2 deletions
|
|
@ -884,9 +884,11 @@ elif not defined(useNimRtl):
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
|
||||||
chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
|
chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
|
||||||
if (poStdErrToStdOut in data.options):
|
chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
|
||||||
chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
|
if poStdErrToStdOut in data.options:
|
||||||
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
|
chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
|
||||||
|
else:
|
||||||
|
chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
|
||||||
|
|
||||||
var res: cint
|
var res: cint
|
||||||
if data.workingDir.len > 0:
|
if data.workingDir.len > 0:
|
||||||
|
|
|
||||||
32
tests/osproc/tstderr.nim
Normal file
32
tests/osproc/tstderr.nim
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
discard """
|
||||||
|
output: '''--------------------------------------
|
||||||
|
to stderr
|
||||||
|
to stderr
|
||||||
|
--------------------------------------
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
import osproc, os, streams
|
||||||
|
|
||||||
|
const filename = "ta_out".addFileExt(ExeExt)
|
||||||
|
|
||||||
|
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
|
||||||
|
|
||||||
|
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
|
||||||
|
options={})
|
||||||
|
|
||||||
|
try:
|
||||||
|
let stdoutStream = p.outputStream
|
||||||
|
let stderrStream = p.errorStream
|
||||||
|
var x = newStringOfCap(120)
|
||||||
|
var output = ""
|
||||||
|
while stderrStream.readLine(x.TaintedString):
|
||||||
|
output.add(x & "\n")
|
||||||
|
|
||||||
|
echo "--------------------------------------"
|
||||||
|
stdout.flushFile()
|
||||||
|
stderr.write output
|
||||||
|
stderr.flushFile()
|
||||||
|
echo "--------------------------------------"
|
||||||
|
stdout.flushFile()
|
||||||
|
finally:
|
||||||
|
p.close()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue