xtd 0.2.0
Loading...
Searching...
No Matches
xtd::native::process Class Referencefinal

Definition

Contains process native API.

Namespace
xtd::native
Library
xtd.core.native
Warning
Internal use only

Protected alias

using started_process = std::tuple< intmax_t, int32_t, std::unique_ptr< std::ostream >, std::unique_ptr< std::istream >, std::unique_ptr< std::istream > >
 Contains the created process handle and created standard streams :
 

Protected Static Methods

static int32_t base_priority (int32_t priority)
 Gets the base priority xof the associated process.
 
static bool kill (intmax_t process)
 Kill process.
 
static bool priority_class (intmax_t process, int32_t priority)
 Sets the overall priority category for the associated process.
 
static intmax_t shell_execute (const std::string &verb, const std::string &file_name, const std::string &arguments, const std::string &working_directory, int32_t process_window_style)
 Creates a process with specified file name, specified arguments, specified working directory, specified process creation flags, and specified process window style.
 
static started_process start (const std::string &file_name, const std::string &arguments, const std::string &working_directory, int32_t process_window_style, int32_t process_creation_flags, std::tuple< bool, bool, bool > redirect_standard_streams)
 Starts a process with specified file name, specified arguments, specified working directory, specified process window style, specified process creation flags, and specified boolean tuples that represent redirect standard streams.
 
static bool wait (intmax_t process, int32_t &exit_code)
 Wait process and close handles.
 

Member Typedef Documentation

◆ started_process

using xtd::native::process::started_process = std::tuple<intmax_t, int32_t, std::unique_ptr<std::ostream>, std::unique_ptr<std::istream>, std::unique_ptr<std::istream> >
protected

Contains the created process handle and created standard streams :

  • [0] : The created process handle.
  • [1] : The created process id.
  • [2] : The created ostream for the standard input.
  • [3] : The created istream for the standard output.
  • [4] : The created istream for the standard error.

Member Function Documentation

◆ base_priority()

static int32_t xtd::native::process::base_priority ( int32_t  priority)
staticprotected

Gets the base priority xof the associated process.

Parameters
priorityThe process handle.
Returns
The base priority, which is computed from the process priority class of the associated process. (see priority_class.h file).
Remarks
The following table shows the relationship between the base priority and process priority class values.
Windows base_priority macOS base_priority linux base_priority priority_class
4 PRIO_MIN (-20) PRIO_MIN (-20)  IDLE_PRIORITY_CLASS
6 PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10)  BELOW_NORMAL_PRIORITY_CLASS
8 PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0)  NORMAL_PRIORITY_CLASS
10 PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10)  ABOVE_NORMAL_PRIORITY_CLASS
13 PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15)  HIGH_PRIORITY_CLASS
24 PRIO_MAX (20) PRIO_MAX (20)  REALTIME_PRIORITY_CLASS

◆ kill()

static bool xtd::native::process::kill ( intmax_t  process)
staticprotected

Kill process.

Parameters
processThe process handle to kill.
Returns
true if succeed; otherwise false.
Warning
Internal use only

◆ priority_class()

static bool xtd::native::process::priority_class ( intmax_t  process,
int32_t  priority 
)
staticprotected

Sets the overall priority category for the associated process.

Parameters
processThe process handle to set priority class.
priorityThe priority category for the associated process, from which the base_priority of the process is calculated. (see priority_class.h file).
Returns
true if succeed; otherwise false.
Warning
Internal use only

◆ shell_execute()

static intmax_t xtd::native::process::shell_execute ( const std::string &  verb,
const std::string &  file_name,
const std::string &  arguments,
const std::string &  working_directory,
int32_t  process_window_style 
)
staticprotected

Creates a process with specified file name, specified arguments, specified working directory, specified process creation flags, and specified process window style.

Parameters
file_namethe name of the application file to run in process launched by the shell execute.
argumentsCommand-line arguments to pass when starting the process.
working_directoryThe fully qualified name of the directory that contains the process to be started. The default is an empty string ("").
process_window_styleOne of the values that indicates whether the process is started in a window that is maximized, minimized, normal (neither maximized nor minimized), or not visible. The default is Normal. (see process_window_window_style.h file).
Returns
The created process handle.
Warning
Internal use only

◆ start()

static started_process xtd::native::process::start ( const std::string &  file_name,
const std::string &  arguments,
const std::string &  working_directory,
int32_t  process_window_style,
int32_t  process_creation_flags,
std::tuple< bool, bool, bool >  redirect_standard_streams 
)
staticprotected

Starts a process with specified file name, specified arguments, specified working directory, specified process window style, specified process creation flags, and specified boolean tuples that represent redirect standard streams.

Parameters
file_namethe name of the application file to run in the process.
argumentsCommand-line arguments to pass when starting the process.
working_directoryThe working directory for the process to be started. The default is an empty string ("").
process_window_styleOne of the values that indicates whether the process is started in a window that is maximized, minimized, normal (neither maximized nor minimized), or not visible. The default is Normal. (see process_window_window_style.h file).
process_creation_flagsOne of the values that indicates whether the process is created. (see process_creation_flags.h file).
redirect_standard_streamsTuple for redirect standard streams :
  • [0] : true if input should be read from standard_input; otherwise, false. The default is false.
  • [1] : true if input should be written to standard_output; otherwise, false. The default is false.
  • [2] : true if input should be written to standard_error; otherwise, false. The default is false.
Returns
A process::started_process that contains the created process handle, id and created standard streams.
Warning
Internal use only

◆ wait()

static bool xtd::native::process::wait ( intmax_t  process,
int32_t &  exit_code 
)
staticprotected

Wait process and close handles.

Parameters
processThe process handle to wait.
exitReceives the process exit code.
Returns
true if succeed; otherwise false.
Warning
Internal use only

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