[Lldb-commits] [lldb] [lldb/Host] Enable inheriting "non-inheritable" FDs (PR #126935)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu May 1 03:30:45 PDT 2025


================
@@ -87,3 +89,41 @@ TEST(Host, LaunchProcessSetsArgv0) {
   ASSERT_THAT_ERROR(Host::LaunchProcess(info).takeError(), Succeeded());
   ASSERT_THAT(exit_status.get_future().get(), 0);
 }
+
+#ifdef LLVM_ON_UNIX
+TEST(Host, LaunchProcessDuplicatesHandle) {
+  static constexpr llvm::StringLiteral test_msg("Hello subprocess!");
+
+  SubsystemRAII<FileSystem> subsystems;
+
+  if (test_arg) {
+    Pipe pipe(LLDB_INVALID_PIPE, (lldb::pipe_t)test_arg.getValue());
+    llvm::Expected<size_t> bytes_written =
+        pipe.Write(test_msg.data(), test_msg.size());
+    if (bytes_written && *bytes_written == test_msg.size())
+      exit(0);
----------------
DavidSpickett wrote:

This `if (test_arg)` gets executed when the code below re-launches the gtest executable, right?

Otherwise this just `exit`s and the rest is dead code.

https://github.com/llvm/llvm-project/pull/126935


More information about the lldb-commits mailing list