Updating boost process for supressing console out

This commit is contained in:
Daniel Larimer 2013-06-27 14:51:55 -04:00
parent b59fe17562
commit 7b18403310
4 changed files with 22 additions and 3 deletions

View file

@ -79,6 +79,14 @@ public:
return (it != handles_.end()) ? it->second : handle();
}
#if defined(BOOST_WINDOWS_API)
handle::native_type get_os_handle() const
{
return handle_.native();
}
#endif
private:
/**
* Handles providing access to streams attached to the child process.

View file

@ -82,6 +82,11 @@ struct context
*/
environment env;
/**
* Suppress creation of a console window on win32 (nop on other platforms)
*/
bool suppress_console;
/**
* Constructs a process context.
*
@ -91,7 +96,8 @@ struct context
*/
context()
: work_dir(self::get_work_dir()),
env(self::get_environment())
env(self::get_environment()),
suppress_console(false)
{
#if 0 // this default behavior will throw in non-console apps
#if defined(BOOST_POSIX_API)

View file

@ -346,7 +346,11 @@ inline child create_child(const std::string &executable, Arguments args,
boost::shared_array<char> envstrs =
detail::environment_to_windows_strings(ctx.env);
if (CreateProcessA(exe.get(), cmdline.get(), NULL, NULL, TRUE, 0,
DWORD creation_flags = 0;
if (ctx.suppress_console)
creation_flags |= CREATE_NO_WINDOW;
if (CreateProcessA(exe.get(), cmdline.get(), NULL, NULL, TRUE, creation_flags,
envstrs.get(), workdir.get(), &startup_info, &pi) == 0)
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("CreateProcess() failed");

View file

@ -198,11 +198,12 @@ private:
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("OpenProcess() failed");
return h;
}
protected:
/**
* The process handle.
*/
handle handle_;
private:
#endif
};