Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63829 - in sandbox/SOC/2010/process: boost/process boost/process/detail libs/process/example
From: boris_at_[hidden]
Date: 2010-07-10 18:20:43


Author: bschaeling
Date: 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
New Revision: 63829
URL: http://svn.boost.org/trac/boost/changeset/63829

Log:
Quick review
Text files modified:
   sandbox/SOC/2010/process/boost/process/child.hpp | 4 --
   sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp | 1
   sandbox/SOC/2010/process/boost/process/operations.hpp | 37 +++++++++++---------------
   sandbox/SOC/2010/process/boost/process/status.hpp | 54 ----------------------------------------
   sandbox/SOC/2010/process/boost/process/stream_behavior.hpp | 3 --
   sandbox/SOC/2010/process/libs/process/example/create_process.cpp | 1
   6 files changed, 17 insertions(+), 83 deletions(-)

Modified: sandbox/SOC/2010/process/boost/process/child.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/child.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/child.hpp 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
@@ -22,10 +22,6 @@
 #include <boost/process/config.hpp>
 
 #if defined(BOOST_POSIX_API)
-# include <boost/process/pipe.hpp>
-# include <boost/process/detail/posix_helpers.hpp>
-# include <map>
-# include <unistd.h>
 #elif defined(BOOST_WINDOWS_API)
 # include <windows.h>
 #else

Modified: sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
@@ -22,6 +22,7 @@
 #define BOOST_PROCESS_WIN32_HELPERS_HPP
 
 #include <boost/process/config.hpp>
+#include <boost/process/environment.hpp>
 #include <boost/shared_array.hpp>
 #include <string>
 #include <vector>

Modified: sandbox/SOC/2010/process/boost/process/operations.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/operations.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/operations.hpp 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
@@ -33,7 +33,6 @@
 # include <boost/process/detail/win32_helpers.hpp>
 # include <boost/algorithm/string/predicate.hpp>
 # include <windows.h>
-# include <boost/process/status.hpp>
 #else
 # error "Unsupported platform."
 #endif
@@ -179,13 +178,10 @@
     args.insert(args.begin(), p_name);
 
 #if defined(BOOST_POSIX_API)
- child::id_type pid;
- pid = ::fork();
-
+ pid_t pid = ::fork();
     if (pid == -1)
- BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("fork(2) failed");
-
- if (pid == 0)
+ BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("fork(2) failed");
+ else if (pid == 0)
     {
 #if defined(F_MAXFD)
         int maxdescs = ::fcntl(-1, F_MAXFD, 0);
@@ -229,44 +225,43 @@
         {
             ::write(STDERR_FILENO, e.what(), std::strlen(e.what()));
             ::write(STDERR_FILENO, "\n", 1);
- std::exit(EXIT_FAILURE);
+ std::exit(127);
         }
 
         std::pair<std::size_t, char**> argcv = detail::collection_to_posix_argv(args);
         char **envp = detail::environment_to_envp(ctx.environment);
+
         ::execve(executable.c_str(), argcv.second, envp);
 
         for (std::size_t i = 0; i < argcv.first; ++i)
             delete[] argcv.second[i];
         delete[] argcv.second;
 
- for (std::size_t i = 0; i < sizeof(envp); ++i)
+ for (std::size_t i = 0; i < ctx.environment.size(); ++i)
             delete[] envp[i];
         delete[] envp;
 
- BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("execve() failed");
- std::exit(EXIT_FAILURE);
-
+ boost::system::system_error e(boost::system::error_code(errno, boost::system::get_system_category()), BOOST_PROCESS_SOURCE_LOCATION "execve(2) failed");
+ ::write(STDERR_FILENO, e.what(), std::strlen(e.what()));
+ ::write(STDERR_FILENO, "\n", 1);
+ std::exit(127);
     }
     else
     {
         BOOST_ASSERT(pid > 0);
 
- //Is this really necessary?
- if(ctx.stdin_behavior->get_child_end() != -1)
+ if (ctx.stdin_behavior->get_child_end() != -1)
             ::close(ctx.stdin_behavior->get_child_end());
- if(ctx.stdout_behavior->get_child_end() != -1)
+ if (ctx.stdout_behavior->get_child_end() != -1)
             ::close(ctx.stdout_behavior->get_child_end());
- if(ctx.stderr_behavior->get_child_end() != -1)
+ if (ctx.stderr_behavior->get_child_end() != -1)
             ::close(ctx.stderr_behavior->get_child_end());
 
         return child(pid,
- detail::file_handle(ctx.stdin_behavior->get_parent_end()),
- detail::file_handle(ctx.stdout_behavior->get_parent_end()),
- detail::file_handle(ctx.stderr_behavior->get_parent_end()));
+ detail::file_handle(ctx.stdin_behavior->get_parent_end()),
+ detail::file_handle(ctx.stdout_behavior->get_parent_end()),
+ detail::file_handle(ctx.stderr_behavior->get_parent_end()));
     }
-
-
 #elif defined(BOOST_WINDOWS_API)
     STARTUPINFOA startup_info;
     ::ZeroMemory(&startup_info, sizeof(startup_info));

Modified: sandbox/SOC/2010/process/boost/process/status.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/status.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/status.hpp 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
@@ -19,7 +19,6 @@
 #ifndef BOOST_PROCESS_STATUS_HPP
 #define BOOST_PROCESS_STATUS_HPP
 
-#if defined(BOOST_WINDOWS_API)
 #include <boost/process/config.hpp>
 #include <boost/process/detail/basic_status.hpp>
 #include <boost/process/detail/basic_status_service.hpp>
@@ -31,56 +30,3 @@
 
 }
 }
-#endif
-#if defined(BOOST_POSIX_API)
-
-//Old status implementation
-class status
-{
- friend class process;
-
-public:
- /**
- * Returns whether the process exited gracefully or not.
- */
- bool exited() const
- {
- return WIFEXITED(flags_);
- }
-
- /**
- * If exited, returns the exit code.
- *
- * If the process exited, returns the exit code it returned.
- *
- * \pre exited() is true.
- */
-
- int exit_code() const
- {
- BOOST_ASSERT(exited());
-
- return WEXITSTATUS(flags_);
- }
-
-protected:
- /**
- * Creates a status object based on exit information.
- *
- * Creates a new status object representing the exit status of a
- * child process.
- *
- * \param flags In a POSIX system this parameter contains the
- * flags returned by the ::waitpid() call. In a
- * Windows system it contains the exit code only.
- */
- status(int flags)
- : flags_(flags) {}
-
- /**
- * OS-specific codification of exit status.
- */
- int flags_;
-};
-#endif
-#endif

Modified: sandbox/SOC/2010/process/boost/process/stream_behavior.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/stream_behavior.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/stream_behavior.hpp 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
@@ -115,9 +115,6 @@
         if (!::DuplicateHandle(::GetCurrentProcess(), child_end_, ::GetCurrentProcess(), &child_end_, 0, TRUE, DUPLICATE_SAME_ACCESS))
             BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("DuplicateHandle() failed");
 #endif
-#if defined(BOOST_POSIX_API)
- //Do nothing since is the default.
-#endif
     }
 
     static boost::shared_ptr<inherit> def(native_type child_end)

Modified: sandbox/SOC/2010/process/libs/process/example/create_process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/create_process.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/example/create_process.cpp 2010-07-10 18:20:42 EDT (Sat, 10 Jul 2010)
@@ -11,7 +11,6 @@
 //
 
 #include <boost/process/all.hpp>
-#include <boost/make_shared.hpp>
 #include <boost/assign/list_of.hpp>
 #include <vector>
 #include <string>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk