Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 24016 invoked from network); 18 Jan 2010 14:25:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jan 2010 14:25:09 -0000 Received: (qmail 71108 invoked by uid 500); 18 Jan 2010 14:25:08 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 71025 invoked by uid 500); 18 Jan 2010 14:25:08 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 71016 invoked by uid 99); 18 Jan 2010 14:25:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 14:25:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 14:25:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 261A923889FF; Mon, 18 Jan 2010 14:24:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r900406 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_exec.h os/unix/exec.c os/win32/exec.c os/win32/subproc.c Date: Mon, 18 Jan 2010 14:24:47 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100118142447.261A923889FF@eris.apache.org> Author: mturk Date: Mon Jan 18 14:24:46 2010 New Revision: 900406 URL: http://svn.apache.org/viewvc?rev=900406&view=rev Log: Add option to redirect stderr to null and just have stdout Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h?rev=900406&r1=900405&r2=900406&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_exec.h Mon Jan 18 14:24:46 2010 @@ -85,10 +85,10 @@ #define ACR_PROC_HAS_STDIN 0x0001 #define ACR_PROC_HAS_STDOUT 0x0002 #define ACR_PROC_HAS_STDERR 0x0004 -#define ACR_PROC_OUTPUT_COMBINE 0x000A -#define ACR_PROC_USE_PATH 0x0010 -#define ACR_PROC_DETACHED 0x0100 -#define ACR_PROC_SUBPROC 0x0200 +#define ACR_PROC_NUL_STDERR 0x0010 +#define ACR_PROC_USE_PATH 0x0100 +#define ACR_PROC_DETACHED 0x0200 +#define ACR_PROC_SUBPROC 0x0400 /** * Create new executable object structure Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=900406&r1=900405&r2=900406&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Mon Jan 18 14:24:46 2010 @@ -279,20 +279,23 @@ goto child_cleanup; } if (pipes[PIPE_STDERR_WRS] == -1) { - if (!(ep->flags & ACR_PROC_HAS_STDOUT) || - ((ep->flags & ACR_PROC_OUTPUT_COMBINE) == ACR_PROC_OUTPUT_COMBINE)) - rc = dup2(pipes[PIPE_STDOUT_WRS], STDERR_FILENO); + if (ep->flags & ACR_NUL_STDERR) { + pipes[PIPE_STDERR_WRS] = nullpipe(O_WRONLY, -1); + if (pipes[PIPE_STDERR_WRS] == -1) { + rc = ACR_GET_OS_ERROR(); + goto child_cleanup; + } + } else - rc = nullpipe(O_WRONLY, STDERR_FILENO); + pipes[PIPE_STDERR_WRS] = pipes[PIPE_STDOUT_WRS]; } - else - rc = dup2(pipes[PIPE_STDERR_WRS], STDERR_FILENO); - if (rc == -1) { + if (dup2(pipes[PIPE_STDERR_WRS], STDERR_FILENO) == -1) { rc = ACR_GET_OS_ERROR(); goto child_cleanup; } + if (pipes[PIPE_STDERR_WRS] != pipes[PIPE_STDOUT_WRS] + i_close(&pipes[PIPE_STDERR_WRS]); i_close(&pipes[PIPE_STDOUT_WRS]); - i_close(&pipes[PIPE_STDERR_WRS]); /* Close all descriptors except our pipes * using fdwalk */ Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c?rev=900406&r1=900405&r2=900406&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c Mon Jan 18 14:24:46 2010 @@ -225,7 +225,7 @@ goto cleanup; } else { - /* Use NUL (aka /dev/null) */ + /* Redirect stdout to NUL */ pipes[PIPE_STDOUT_WRS] = nullpipe(GENERIC_WRITE, NULL); } if (ep->flags & ACR_PROC_HAS_STDERR) { @@ -234,14 +234,15 @@ goto cleanup; } else { - if (!(ep->flags & ACR_PROC_HAS_STDOUT) || - ((ep->flags & ACR_PROC_OUTPUT_COMBINE) == ACR_PROC_OUTPUT_COMBINE)) { + if (ep->flags & ACR_PROC_NUL_STDERR)) { + /* Redirect stderr to NUL */ + pipes[PIPE_STDERR_WRS] = nullpipe(GENERIC_WRITE, NULL); + } + else { /* Use same pipes for stderr and stdout */ pipes[PIPE_STDERR_WRS] = pipes[PIPE_STDOUT_WRS]; } - else - pipes[PIPE_STDERR_WRS] = nullpipe(GENERIC_WRITE, NULL); } /* Always use STDHANDLES * They are either real handles or handles to NUL device Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c?rev=900406&r1=900405&r2=900406&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c Mon Jan 18 14:24:46 2010 @@ -210,14 +210,6 @@ child.flags |= ACR_PROC_HAS_STDOUT; } break; - case L'C': - /* Where the child stdout should be redirected */ - if (opt) { - wcslcpy(po_name, pfx, sizeof(po_name)); - wcslcat(po_name, opt, sizeof(po_name)); - child.flags |= ACR_PROC_OUTPUT_COMBINE; - } - break; case L'E': /* Where the child stderr should be redirected */ if (opt) { @@ -225,6 +217,8 @@ wcslcat(pe_name, opt, sizeof(pe_name)); child.flags |= ACR_PROC_HAS_STDERR; } + else + child.flags |= ACR_PROC_NUL_STDERR; break; case L'D': /* Detached process */ @@ -352,14 +346,15 @@ } } else { - if (!(child.flags & ACR_PROC_HAS_STDOUT) || - ((child.flags & ACR_PROC_OUTPUT_COMBINE) == ACR_PROC_OUTPUT_COMBINE)) { + if (child.flags & ACR_PROC_NUL_STDERR)) { + /* Redirect stderr to NUL */ + pipes[PIPE_STDERR_WRS] = nullpipe(GENERIC_WRITE, NULL); + } + else { /* Use same pipes for stderr and stdout */ pipes[PIPE_STDERR_WRS] = pipes[PIPE_STDOUT_WRS]; } - else - pipes[PIPE_STDERR_WRS] = nullpipe(GENERIC_WRITE, NULL); } /* Always use STDHANDLES @@ -824,6 +819,10 @@ suba[subn] = s_malloc(wchar_t, 64); _snwprintf(suba[subn++], 64, L"--E:%s", childpname[PIPE_STDERR_RPC] + 9); } + else if (ep->flags & ACR_PROC_NUL_STDERR) { + /* --E without pipe name will force NUL for stderr */ + suba[subn++] = x_wcsdup(L"--E"); + } suba[subn++] = ACR_wcsdup(executable); suba[subn] = NULL; /* Merge the new array with the provided arguments