From dd2e3903bc6eb09fec002f67c2723cda51713251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Thu, 25 Jun 2015 12:33:15 +0200 Subject: [PATCH] run-program: handle `error' parameter value `:output' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel KochmaƄski --- src/c/unixsys.d | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/c/unixsys.d b/src/c/unixsys.d index daed4a52e..b72fa811f 100644 --- a/src/c/unixsys.d +++ b/src/c/unixsys.d @@ -570,7 +570,14 @@ create_descriptor(cl_object stream, cl_object direction, } create_descriptor(input, @':input', &child_stdin, &parent_write); create_descriptor(output, @':output', &child_stdout, &parent_read); - create_descriptor(error, @':output', &child_stderr, &parent_error); + if (error == @':output') + /* The child inherits a duplicate of its own output + handle.*/ + DuplicateHandle(current, child_stdout, current, + &child_stderr, 0, TRUE, + DUPLICATE_SAME_ACCESS); + else + create_descriptor(error, @':output', &child_stderr, &parent_error); add_external_process(the_env, process); #if 1 @@ -643,7 +650,10 @@ create_descriptor(cl_object stream, cl_object direction, create_descriptor(input, @':input', &child_stdin, &parent_write); create_descriptor(output, @':output', &child_stdout, &parent_read); - create_descriptor(error, @':output', &child_stderr, &parent_error); + if (error == @':output') + child_stderr = child_stdout; + else + create_descriptor(error, @':output', &child_stderr, &parent_error); add_external_process(the_env, process); pipe(pipe_fd);