Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62026 - in sandbox/SOC/2010/process/boost/process: . detail
From: fotanus_at_[hidden]
Date: 2010-05-16 04:04:52


Author: fotanus
Date: 2010-05-16 04:04:46 EDT (Sun, 16 May 2010)
New Revision: 62026
URL: http://svn.boost.org/trac/boost/changeset/62026

Log:
Updated the create_child function. Right now it's able to lauch a process, but it fails, most likely because of the env variables.
Text files modified:
   sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp | 158 ++++++++++++++++++++--------------------
   sandbox/SOC/2010/process/boost/process/operations.hpp | 42 +++++-----
   2 files changed, 100 insertions(+), 100 deletions(-)

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-05-16 04:04:46 EDT (Sun, 16 May 2010)
@@ -137,89 +137,89 @@
 
 
 
-void configure_win32_stream(stream_detail &sd, STARTUPINFOA &si){
+void configure_win32_stream(stream_detail &sd, STARTUPINFOA *si){
 
- file_handle return_handle;
+ file_handle return_handle;
 
- switch (sd.behavior){
- case closed:{
+ switch (sd.behavior){
+ case closed:{
 
- break;
- }
- case inherit:{
- return_handle = file_handle::win32_dup_std(sd.stream_handler, true);
- break;
- }
-
- case dummy:{
- HANDLE h;
- if(sd.stream_type == stdin_type){
- h = ::CreateFileA("NUL",
- GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
-
- }
- else{
- h = ::CreateFileA("NUL",
- GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL, NULL);
- }
-
- if (h == INVALID_HANDLE_VALUE)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateFile failed"));
-
- return_handle = file_handle(h);
-
- break;
- }
-
- case capture:{
- if(sd.stream_type == stdin_type){
- sd.object.pipe_->rend().win32_set_inheritable(true);
- return_handle = sd.object.pipe_->rend();
- }
- else{
- sd.object.pipe_->wend().win32_set_inheritable(true);
- return_handle = sd.object.pipe_->wend();
- }
-
- break;
- }
-
- default:{
- BOOST_ASSERT(false);
- break;
- }
- }
-
-
- file_handle h;
-
-
- switch(sd.stream_type){
- case stdin_type:{
- if(return_handle.valid())
- si.hStdInput = return_handle.get();
- else
- si.hStdInput = INVALID_HANDLE_VALUE;
- break;
- }
- case stdout_type:{
- if(return_handle.valid())
- si.hStdOutput = return_handle.get();
- else
- si.hStdOutput = INVALID_HANDLE_VALUE;
- break;
- }
- case stderr_type:{
- if(return_handle.valid())
- si.hStdError = return_handle.get();
- else
- si.hStdError = INVALID_HANDLE_VALUE;
- break;
- }
+ break;
+ }
+ case inherit:{
+ return_handle = file_handle::win32_dup_std(sd.stream_handler, true);
+ break;
+ }
+
+ case dummy:{
+ HANDLE h;
+ if(sd.stream_type == stdin_type){
+ h = ::CreateFileA("NUL",
+ GENERIC_READ, 0, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+
+ }
+ else{
+ h = ::CreateFileA("NUL",
+ GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ }
+
+ if (h == INVALID_HANDLE_VALUE)
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateFile failed"));
+
+ return_handle = file_handle(h);
+
+ break;
+ }
+
+ case capture:{
+ if(sd.stream_type == stdin_type){
+ sd.object.pipe_->rend().win32_set_inheritable(true);
+ return_handle = sd.object.pipe_->rend();
+ }
+ else{
+ sd.object.pipe_->wend().win32_set_inheritable(true);
+ return_handle = sd.object.pipe_->wend();
+ }
+
+ break;
+ }
+
+ default:{
+ BOOST_ASSERT(false);
+
+ }
+ }
+
+
+ file_handle h;
+
+
+ switch(sd.stream_type){
+ case stdin_type:{
+ if(return_handle.valid())
+ (*si).hStdInput = return_handle.get();
+ else
+ (*si).hStdInput = INVALID_HANDLE_VALUE;
+ break;
+ }
+ case stdout_type:{
+ if(return_handle.valid())
+ (*si).hStdOutput = return_handle.get();
+ else
+ (*si).hStdOutput = INVALID_HANDLE_VALUE;
+ break;
+ }
+ case stderr_type:{
+ if(return_handle.valid())
+ (*si).hStdError = return_handle.get();
+ else
+ (*si).hStdError = INVALID_HANDLE_VALUE;
+ break;
+ }
 
- }
+ }
 
 }
 

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-05-16 04:04:46 EDT (Sun, 16 May 2010)
@@ -269,47 +269,47 @@
 #elif defined(BOOST_WINDOWS_API)
 
 
- //Set up the pipes when needed for the current process.
- if (stdin_stream.behavior == capture)
- fhstdin = stdin_stream.object.pipe_->wend();
- if (stdin_stream.behavior == capture)
- fhstdin = stdin_stream.object.pipe_->wend();
- if (stdin_stream.behavior == capture)
- fhstdin = stdin_stream.object.pipe_->wend();
+ //Set up the pipes when needed for the current process.
+ if (stdin_stream.behavior == capture)
+ fhstdin = stdin_stream.object.pipe_->wend();
+ if (stdin_stream.behavior == capture)
+ fhstdin = stdin_stream.object.pipe_->wend();
+ if (stdin_stream.behavior == capture)
+ fhstdin = stdin_stream.object.pipe_->wend();
 
- //define startup info from the new child
+ //define startup info from the new child
         STARTUPINFOA start_up_info;
         ::ZeroMemory(&start_up_info, sizeof(start_up_info));
         start_up_info.cb = sizeof(start_up_info);
 
- start_up_info.dwFlags |= STARTF_USESTDHANDLES;
+ start_up_info.dwFlags |= STARTF_USESTDHANDLES;
                 
- configure_win32_stream(stdin_stream, start_up_info);
- configure_win32_stream(stdout_stream, start_up_info);
- configure_win32_stream(stderr_stream, start_up_info);
+ configure_win32_stream(stdin_stream, &start_up_info);
+ configure_win32_stream(stdout_stream, &start_up_info);
+ configure_win32_stream(stderr_stream, &start_up_info);
 
- //define basic info to start the process
+ //define basic info to start the process
             PROCESS_INFORMATION pi;
             ::ZeroMemory(&pi, sizeof(pi));
 
             boost::shared_array<char> cmdline = detail::collection_to_win32_cmdline(args);
 
- boost::scoped_array<char> exe(new char[executable.size() + 1]);
- ::strcpy_s(exe.get(), executable.size() + 1, executable.c_str());
+ boost::scoped_array<char> exe(new char[executable.size() + 1]);
+ ::strcpy_s(exe.get(), executable.size() + 1, executable.c_str());
 
             boost::scoped_array<char> workdir(new char[ctx.work_dir.size() + 1]);
- ::strcpy_s(workdir.get(), ctx.work_dir.size() + 1, ctx.work_dir.c_str());
+ ::strcpy_s(workdir.get(), ctx.work_dir.size() + 1, ctx.work_dir.c_str());
                 
 
- boost::shared_array<char> envstrs = detail::environment_to_win32_strings(ctx.environment);
+ boost::shared_array<char> envstrs = detail::environment_to_win32_strings(ctx.environment);
 
- if ( ! ::CreateProcessA(exe.get(), cmdline.get(),
- NULL, NULL, TRUE, 0, envstrs.get(), workdir.get(),
+ if ( ! ::CreateProcessA(exe.get(), cmdline.get(),
+ NULL, NULL, TRUE, 0, envstrs.get(), workdir.get(),
                         &start_up_info, &pi))
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateProcess failed"));
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateProcess failed"));
 
         if (! ::CloseHandle(pi.hThread))
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::launch: CloseHandle failed"));
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::launch: CloseHandle failed"));
 
         return child(pi.dwProcessId, fhstdin, fhstdout, fhstderr, detail::file_handle(pi.hProcess));
 


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