LLDB mainline
lldb_private::ProcessLauncherWindows Class Reference

#include <ProcessLauncherWindows.h>

Inheritance diagram for lldb_private::ProcessLauncherWindows:
[legend]

Public Member Functions

HostProcess LaunchProcess (const ProcessLaunchInfo &launch_info, Status &error) override
Public Member Functions inherited from lldb_private::ProcessLauncher
virtual ~ProcessLauncher ()=default

Static Protected Member Functions

static llvm::ErrorOr< std::vector< HANDLE > > GetInheritedHandles (STARTUPINFOEXW &startupinfoex, const ProcessLaunchInfo *launch_info=nullptr, HANDLE stdout_handle=NULL, HANDLE stderr_handle=NULL, HANDLE stdin_handle=NULL)
 Get the list of Windows handles that should be inherited by the child process and update STARTUPINFOEXW with the handle list.
static HANDLE GetStdioHandle (const ProcessLaunchInfo &launch_info, int fd)
static HANDLE GetStdioHandle (const llvm::StringRef path, int fd)
 Creates a file handle suitable for redirecting stdin, stdout, or stderr of a child process.

Detailed Description

Definition at line 79 of file ProcessLauncherWindows.h.

Member Function Documentation

◆ GetInheritedHandles()

llvm::ErrorOr< std::vector< HANDLE > > ProcessLauncherWindows::GetInheritedHandles ( STARTUPINFOEXW & startupinfoex,
const ProcessLaunchInfo * launch_info = nullptr,
HANDLE stdout_handle = NULL,
HANDLE stderr_handle = NULL,
HANDLE stdin_handle = NULL )
staticprotected

Get the list of Windows handles that should be inherited by the child process and update STARTUPINFOEXW with the handle list.

If no handles need to be inherited, an empty vector is returned.

Otherwise, the function populates the PROC_THREAD_ATTRIBUTE_HANDLE_LIST attribute in startupinfoex with the collected handles using UpdateProcThreadAttribute. On success, the vector of inherited handles is returned.

Parameters
startupinfoexThe extended STARTUPINFO structure for the process being created.
launch_infoThe process launch configuration.
stdout_handle
stderr_handle
stdin_handleOptional explicit standard stream handles to use for the child process.
Returns
std::vector<HANDLE> containing all handles that the child must inherit.

Definition at line 237 of file ProcessLauncherWindows.cpp.

References lldb_private::FileAction::eFileActionDuplicate, lldb_private::FileAction::GetAction(), lldb_private::FileAction::GetActionArgument(), lldb_private::FileAction::GetFD(), lldb_private::ProcessLaunchInfo::GetFileActionAtIndex(), and lldb_private::ProcessLaunchInfo::GetNumFileActions().

Referenced by LaunchProcess().

◆ GetStdioHandle() [1/2]

HANDLE ProcessLauncherWindows::GetStdioHandle ( const llvm::StringRef path,
int fd )
staticprotected

Creates a file handle suitable for redirecting stdin, stdout, or stderr of a child process.

Parameters
pathThe file path to open. If empty, returns NULL (no redirection).
fdThe file descriptor type: STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO.
Returns
A handle to the opened file, or NULL if the path is empty or the file cannot be opened (INVALID_HANDLE_VALUE is converted to NULL).

Behavior by file descriptor:

  • STDIN_FILENO: Opens existing file for reading (GENERIC_READ, OPEN_EXISTING).
  • STDOUT_FILENO: Creates/truncates file for writing (GENERIC_WRITE, CREATE_ALWAYS).
  • STDERR_FILENO: Creates/truncates file for writing with write-through (FILE_FLAG_WRITE_THROUGH ensures immediate disk writes, bypassing system cache for error messages).

All handles are created with:

  • Inheritance enabled (bInheritHandle = TRUE) so child processes can use them.
  • Shared read/write/delete access to allow other processes to access the file.

Definition at line 289 of file ProcessLauncherWindows.cpp.

◆ GetStdioHandle() [2/2]

HANDLE ProcessLauncherWindows::GetStdioHandle ( const ProcessLaunchInfo & launch_info,
int fd )
staticprotected

◆ LaunchProcess()


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