24#ifndef _PROCESS_LAUNCHER_H_
25#define _PROCESS_LAUNCHER_H_
33#include <system_error>
38#define _CRT_SECURE_NO_WARNINGS 1
47#include "harness_export.h"
56HARNESS_EXPORT std::string cmdline_quote_arg(
const std::string &arg);
57HARNESS_EXPORT std::string cmdline_from_args(
58 const std::string &executable_path,
const std::vector<std::string> &args);
76 std::vector<std::pair<std::string, std::string>> penv_vars,
77 bool predirect_stderr =
true)
78 : executable_path{
std::move(pexecutable_path)},
79 args{
std::move(pargs)},
80 env_vars{
std::move(penv_vars)},
82 child_in_rd{INVALID_HANDLE_VALUE},
83 child_in_wr{INVALID_HANDLE_VALUE},
84 child_out_rd{INVALID_HANDLE_VALUE},
85 child_out_wr{INVALID_HANDLE_VALUE},
93 redirect_stderr{predirect_stderr} {
108 std::string get_cmd_line()
const;
114 const std::vector<std::string>
args;
115 const std::vector<std::pair<std::string, std::string>>
env_vars;
121 PROCESS_INFORMATION pi;
145 bool child_in_wr_closed =
false;
157 std::vector<std::pair<std::string, std::string>> penv_vars,
158 bool predirect_stderr =
true)
160 std::move(penv_vars), predirect_stderr),
173 rhs.is_alive =
false;
198 int write(
const char *
buf,
size_t count);
203 exit_status_type kill();
231 int wait(std::chrono::milliseconds
timeout = std::chrono::milliseconds(1000));
234 std::chrono::milliseconds
timeout = std::chrono::milliseconds(1000));
254 std::error_code send_shutdown_event(
255 ShutdownEvent
event = ShutdownEvent::TERM)
const noexcept;
266 exit_status_type
close();
exit status of processes.
Definition: exit_status.h:47
Definition: process_launcher.h:136
bool is_alive
Definition: process_launcher.h:271
ProcessLauncher(std::string pexecutable_path, std::vector< std::string > pargs, std::vector< std::pair< std::string, std::string > > penv_vars, bool predirect_stderr=true)
Creates a new process and launch it.
Definition: process_launcher.h:156
SpawnedProcess::id_type process_id_type
Definition: process_launcher.h:206
ProcessLauncher(ProcessLauncher &&rhs)
Definition: process_launcher.h:168
std::mutex fd_out_mtx_
Definition: process_launcher.h:269
ProcessLauncher operator=(const ProcessLauncher &)=delete
std::mutex fd_in_mtx_
Definition: process_launcher.h:268
ShutdownEvent
Definition: process_launcher.h:242
SpawnedProcess::handle_type process_handle_type
Definition: process_launcher.h:205
ProcessLauncher(const ProcessLauncher &)=delete
an alive, spawned process
Definition: process_launcher.h:73
virtual ~SpawnedProcess()=default
const std::vector< std::pair< std::string, std::string > > env_vars
Definition: process_launcher.h:115
SpawnedProcess(const SpawnedProcess &)=default
bool redirect_stderr
Definition: process_launcher.h:128
pid_t id_type
Definition: process_launcher.h:105
pid_t handle_type
Definition: process_launcher.h:104
SpawnedProcess(std::string pexecutable_path, std::vector< std::string > pargs, std::vector< std::pair< std::string, std::string > > penv_vars, bool predirect_stderr=true)
Definition: process_launcher.h:75
pid_t childpid
Definition: process_launcher.h:124
std::string executable() const
Definition: process_launcher.h:110
const std::string executable_path
Definition: process_launcher.h:113
const std::vector< std::string > args
Definition: process_launcher.h:114
Definition: expected.h:286
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
static int count
Definition: myisam_ftdump.cc:45
Definition: buf0block_hint.cc:30
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:498
static int wait(mysql_cond_t *that, mysql_mutex_t *mutex_arg, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:63
stdx::expected< void, std::error_code > close(file_handle_type native_handle)
close file handle.
Definition: file.h:239
Definition: gcs_xcom_synode.h:64
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
required string event
Definition: replication_group_member_actions.proto:32
@ KILL
Definition: task.h:232
#define HANDLE
Definition: violite.h:159