commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
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 GMT
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



Mime
View raw message