boost::process

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

boost::process

Boost - Users mailing list
Hi,

I'm trying to use Boost 1.65.1's boost::process::child in a Windows
console program.

At the moment, the child process is launched in the same console window
as the parent.

Is there an option to make a new console window for the child?

The pre-boost-incorporation version of boost::process seemed to allow
manipulation of the startupInfo struct directly (e.g.
https://stackoverflow.com/questions/43582022/boostprocess-hide-console-on-windows/43583001)
and then a win32_launch call. But this seems to have been removed now?

Any tips gratefully received.

Thanks,

Chris.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::process

Boost - Users mailing list
To answer my own question - this is one working possibility using
boost::process::extend...

#include <boost/process.hpp>
#include <boost/process/extend.hpp>

int main()
{
        boost::filesystem::path myPath(".........toRun.exe.......");

        auto set_own_window = [](auto & exec)
        {
            exec.creation_flags |=
boost::detail::winapi::CREATE_NEW_CONSOLE_;
            std::cerr << "in set_own_window" << std::endl; /* just for
debugging */
        };

        bp::child c(myPath, "argument1",
boost::process::extend::on_setup=set_own_window);

    return 0;
}

This works. Is it the right approach, or is there a better way?

Best wishes,

Chris.

On 05/10/2017 17:14, Chris Rodgers wrote:

> Hi,
>
> I'm trying to use Boost 1.65.1's boost::process::child in a Windows
> console program.
>
> At the moment, the child process is launched in the same console window
> as the parent.
>
> Is there an option to make a new console window for the child?
>
> The pre-boost-incorporation version of boost::process seemed to allow
> manipulation of the startupInfo struct directly (e.g.
> https://stackoverflow.com/questions/43582022/boostprocess-hide-console-on-windows/43583001)
> and then a win32_launch call. But this seems to have been removed now?
>
> Any tips gratefully received.
>
> Thanks,
>
> Chris.
>

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users