================
@@ -102,12 +106,58 @@ class ProcessLauncherWindows : public ProcessLauncher {
/// \returns
/// `std::vector<HANDLE>` containing all handles that the child must
/// inherit.
- llvm::ErrorOr<std::vector<HANDLE>>
- GetInheritedHandles(const ProcessLaunchInfo &launch_info,
- STARTUPINFOEXW &startupinfoex,
+ 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);
+
+ static HANDLE GetStdioHandle(const ProcessLaunchInfo &launch_info, int fd);
+
+ /// Creates a file handle suitable for redirecting stdin, stdout,
+ /// or stderr of a child process.
+ ///
+ /// \param path The file path to open. If empty, returns NULL (no
+ /// redirection).
+ /// \param fd The file descriptor type: STDIN_FILENO, STDOUT_FILENO, or
+ /// STDERR_FILENO.
+ ///
+ /// \return 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.
+ static HANDLE GetStdioHandle(const llvm::StringRef path, int fd);
};
+
+/// Flattens an Args object into a Windows command-line wide string.
+///
+/// Returns an empty string if args is empty.
+///
+/// \param args The Args object to flatten.
+/// \returns A wide string containing the flattened command line.
+llvm::ErrorOr<std::wstring> GetFlattenedWindowsCommandStringW(Args args);
+
+/// Flattens an Args object into a Windows command-line wide string.
+///
+/// Returns an empty string if args is empty.
+///
+/// \param args The Args object to flatten.
+/// \returns A wide string containing the flattened command line.
+llvm::ErrorOr<std::wstring> GetFlattenedWindowsCommandStringW(char *args[]);
----------------
Nerixyz wrote:
Could these get passed as an `llvm::ArrayRef`?
I don't think this needs a documentation comment - there's one above already.
https://github.com/llvm/llvm-project/pull/183579
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits