myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [2990] Fixed test failure.


From: Giuseppe Scrivano
Subject: [myserver-commit] [2990] Fixed test failure.
Date: Sun, 01 Feb 2009 14:58:31 +0000

Revision: 2990
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2990
Author:   gscrivano
Date:     2009-02-01 14:58:30 +0000 (Sun, 01 Feb 2009)

Log Message:
-----------
Fixed test failure.  Don't dup stderr file to the stdout descriptor.

Modified Paths:
--------------
    trunk/myserver/src/base/process/process.cpp
    trunk/myserver/src/http_handler/cgi/cgi.cpp
    trunk/myserver/tests/test_fork_server.cpp

Modified: trunk/myserver/src/base/process/process.cpp
===================================================================
--- trunk/myserver/src/base/process/process.cpp 2009-01-31 23:00:24 UTC (rev 
2989)
+++ trunk/myserver/src/base/process/process.cpp 2009-02-01 14:58:30 UTC (rev 
2990)
@@ -219,7 +219,6 @@
       if (spi->uid)
         Process::setuid (spi->uid);
 
-
       if (generateArgList (args, spi->cmd.c_str (), spi->arg))
         exit (1);
 
@@ -239,29 +238,24 @@
       if ((long)spi->stdError == -1)
         spi->stdError = (FileHandle)open ("/dev/null", O_WRONLY);
 
-      // map stdio to files
-      if (close(0) == -1) // close stdin
-        exit (1);
+      close(0);
 
       if (spi->stdIn != -1)
         {
           if (dup2 (spi->stdIn, 0) == -1)
             exit (1);
-          
-          if (close (spi->stdIn) == -1)
-            exit (1);
+          close (spi->stdIn);
         }
 
-      if (close (1) == -1) // close stdout
-        exit (1);
+      close (1);
 
       if (dup2 (spi->stdOut, 1) == -1)
         exit (1);
 
-      if (close (2) == -1) // close stderr
-        exit (1);
 
-      if (dup2 (spi->stdError, 1) == -1)
+      close (2);
+
+      if (dup2 (spi->stdError, 2) == -1)
         exit (1);
       
       if (spi->handlesToClose)
@@ -269,12 +263,11 @@
           FileHandle* h = spi->handlesToClose;
           while (*h)
             {
-              if (close (*h) == -1)
-                exit (1);
+              close (*h);
               h++;
             }
         }
-      // Run the script
+
       execve ((const char*)args[0], 
               (char* const*)args, (char* const*) envp);
 

Modified: trunk/myserver/src/http_handler/cgi/cgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/cgi/cgi.cpp 2009-01-31 23:00:24 UTC (rev 
2989)
+++ trunk/myserver/src/http_handler/cgi/cgi.cpp 2009-02-01 14:58:30 UTC (rev 
2990)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or

Modified: trunk/myserver/tests/test_fork_server.cpp
===================================================================
--- trunk/myserver/tests/test_fork_server.cpp   2009-01-31 23:00:24 UTC (rev 
2989)
+++ trunk/myserver/tests/test_fork_server.cpp   2009-02-01 14:58:30 UTC (rev 
2990)
@@ -71,7 +71,7 @@
         int pid = 0;
         int port = 0;
         StartProcInfo spi;
-        char buffer [32];
+        char buffer [32] = {'\0'};
         const char *msg = "ForkServer";
         u_long nbr;
         int ret = fs->startForkServer ();
@@ -79,7 +79,8 @@
         Pipe pipe;
         pipe.create();
     
-        spi.stdIn = spi.stdError = -1;
+        spi.stdIn = -1;
+        spi.stdError = -1;
         spi.stdOut =  pipe.getWriteHandle();
 
         spi.cmd.assign ("/bin/echo");
@@ -88,9 +89,9 @@
         spi.envString = NULL;
 
         ret = fs->executeProcess (&spi, ForkServer::FLAG_USE_OUT, &pid, &port);
+        pipe.closeWrite ();
 
         CPPUNIT_ASSERT_EQUAL (ret, 0);
-        pipe.closeWrite ();
 
         ret = pipe.read (buffer, 32, &nbr);
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]