本文整理汇总了C++中ProcessLaunchInfo::AppendSuppressFileAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ProcessLaunchInfo::AppendSuppressFileAction方法的具体用法?C++ ProcessLaunchInfo::AppendSuppressFileAction怎么用?C++ ProcessLaunchInfo::AppendSuppressFileAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProcessLaunchInfo
的用法示例。
在下文中一共展示了ProcessLaunchInfo::AppendSuppressFileAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getenv
//.........这里部分代码省略.........
}
const char *env_debugserver_log_flags = getenv("LLDB_DEBUGSERVER_LOG_FLAGS");
if (env_debugserver_log_flags)
{
::snprintf (arg_cstr, sizeof(arg_cstr), "--log-flags=%s", env_debugserver_log_flags);
debugserver_args.AppendArgument(arg_cstr);
}
// Add additional args, starting with LLDB_DEBUGSERVER_EXTRA_ARG_1 until an env var doesn't come back.
uint32_t env_var_index = 1;
bool has_env_var;
do
{
char env_var_name[64];
snprintf (env_var_name, sizeof (env_var_name), "LLDB_DEBUGSERVER_EXTRA_ARG_%" PRIu32, env_var_index++);
const char *extra_arg = getenv(env_var_name);
has_env_var = extra_arg != nullptr;
if (has_env_var)
{
debugserver_args.AppendArgument (extra_arg);
if (log)
log->Printf ("GDBRemoteCommunication::%s adding env var %s contents to stub command line (%s)", __FUNCTION__, env_var_name, extra_arg);
}
} while (has_env_var);
// Close STDIN, STDOUT and STDERR.
launch_info.AppendCloseFileAction (STDIN_FILENO);
launch_info.AppendCloseFileAction (STDOUT_FILENO);
launch_info.AppendCloseFileAction (STDERR_FILENO);
// Redirect STDIN, STDOUT and STDERR to "/dev/null".
launch_info.AppendSuppressFileAction (STDIN_FILENO, true, false);
launch_info.AppendSuppressFileAction (STDOUT_FILENO, false, true);
launch_info.AppendSuppressFileAction (STDERR_FILENO, false, true);
error = Host::LaunchProcess(launch_info);
if (error.Success() && launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
{
if (named_pipe_path.size() > 0)
{
error = port_pipe.OpenAsReader(named_pipe_path, false);
if (error.Fail())
if (log)
log->Printf("GDBRemoteCommunication::%s() "
"failed to open named pipe %s for reading: %s",
__FUNCTION__, named_pipe_path.c_str(), error.AsCString());
}
if (port_pipe.CanWrite())
port_pipe.CloseWriteFileDescriptor();
if (port_pipe.CanRead())
{
char port_cstr[256];
port_cstr[0] = '\0';
size_t num_bytes = sizeof(port_cstr);
// Read port from pipe with 10 second timeout.
error = port_pipe.ReadWithTimeout(port_cstr, num_bytes,
std::chrono::seconds{10}, num_bytes);
if (error.Success())
{
assert(num_bytes > 0 && port_cstr[num_bytes-1] == '\0');
out_port = StringConvert::ToUInt32(port_cstr, 0);
if (log)