subprocess  0.4.0
Modern subprocess library for c++
Public Member Functions | Public Attributes | List of all members
subprocess::RunBuilder Struct Reference

#include <ProcessBuilder.hpp>

Collaboration diagram for subprocess::RunBuilder:
Collaboration graph
[legend]

Public Member Functions

 RunBuilder ()
 
 RunBuilder (CommandLine cmd)
 
 RunBuilder (std::initializer_list< std::string > command)
 
RunBuildercheck (bool ch)
 
RunBuildercin (const PipeVar &cin)
 
RunBuildercout (const PipeVar &cout)
 
RunBuildercerr (const PipeVar &cerr)
 
RunBuildercwd (std::string cwd)
 
RunBuilderenv (const EnvMap &env)
 
RunBuildertimeout (double timeout)
 
RunBuildernew_process_group (bool new_group)
 
 operator RunOptions () const
 
CompletedProcess run ()
 
Popen popen ()
 

Public Attributes

RunOptions options
 
CommandLine command
 

Detailed Description

Helper class to construct RunOptions with minimal typing.

Constructor & Destructor Documentation

◆ RunBuilder() [1/3]

subprocess::RunBuilder::RunBuilder ( )
inline

◆ RunBuilder() [2/3]

subprocess::RunBuilder::RunBuilder ( CommandLine  cmd)
inline

Constructs builder with cmd as command to run

◆ RunBuilder() [3/3]

subprocess::RunBuilder::RunBuilder ( std::initializer_list< std::string >  command)
inline

Constructs builder with command to run

Member Function Documentation

◆ cerr()

RunBuilder& subprocess::RunBuilder::cerr ( const PipeVar cerr)
inline

Sets the cerr option. Could be a PipeOption, output handle

◆ check()

RunBuilder& subprocess::RunBuilder::check ( bool  ch)
inline

Only for run(), throws exception if command returns non-zero exit code

◆ cin()

RunBuilder& subprocess::RunBuilder::cin ( const PipeVar cin)
inline

Set the cin option. Could be PipeOption, input handle, std::string with data to pass.

◆ cout()

RunBuilder& subprocess::RunBuilder::cout ( const PipeVar cout)
inline

Sets the cout option. Could be a PipeOption, output handle

◆ cwd()

RunBuilder& subprocess::RunBuilder::cwd ( std::string  cwd)
inline

Sets the current working directory to use for subprocess

◆ env()

RunBuilder& subprocess::RunBuilder::env ( const EnvMap env)
inline

Sets the environment to use. Default is current environment if unset

◆ new_process_group()

RunBuilder& subprocess::RunBuilder::new_process_group ( bool  new_group)
inline

Set to true to run as new process group. On windows the new process has CTRL+C handler disabled so CTRL+C or sending SIGINT won't kill the process. If you want to send CTRL+C you will need to make a new exe that's sole purpose is enabling CTRL+C handling and launching new process and giving process id back to parent process for use.

◆ operator RunOptions()

subprocess::RunBuilder::operator RunOptions ( ) const
inline

◆ popen()

Popen subprocess::RunBuilder::popen ( )
inline

Creates a Popen object running the process asynchronously

Returns
Popen object with current configuration.

◆ run()

CompletedProcess subprocess::RunBuilder::run ( )
inline

Runs the command already configured.

see subprocess::run() for more details.

◆ timeout()

RunBuilder& subprocess::RunBuilder::timeout ( double  timeout)
inline

Timeout to use for run() invocation only.

Member Data Documentation

◆ command

CommandLine subprocess::RunBuilder::command

◆ options

RunOptions subprocess::RunBuilder::options

The documentation for this struct was generated from the following file: