[llvm] [clang-repl] Run by another application shell cause hang. (PR #67513)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 18:46:09 PDT 2023


https://github.com/ormastes created https://github.com/llvm/llvm-project/pull/67513

clang-repl process launched by another application (For example, python Popen and other API's) is hang and does not print any output. fflush() after prompt fix this porblem.

It does not make any performance problem since it is flush() right before waiting input. 

To run clang-repl in jupyter notebook, it should be fixed. After fix it clang-repl run well with jupyter notebook. see: https://github.com/ormastes/jupyter_kernels/tree/main/clang_repl_kernel

>From 63fa9eb773aa0b9f5ec6362e8eb8a980eb93e4f6 Mon Sep 17 00:00:00 2001
From: yoon <ormastes at gmail.com>
Date: Wed, 27 Sep 2023 10:06:17 +0900
Subject: [PATCH] [clang-repl] Run by another application shell cause hang.

clang-repl process launched by another application (For example, python Popen and other API's) is hang and does not print any output.
fflush() after prompt fix this porblem.
It does not make any performance problem since it is flush() right before waiting input.
To run clang-repl in jupyter notebook, it should be fixed.
After fix it clang-repl run well with jupyter notebook.
see: https://github.com/ormastes/jupyter_kernels/tree/main/clang_repl_kernel
---
 llvm/lib/LineEditor/LineEditor.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/LineEditor/LineEditor.cpp b/llvm/lib/LineEditor/LineEditor.cpp
index bb408411a330e6b..15d3ba4dc834cb9 100644
--- a/llvm/lib/LineEditor/LineEditor.cpp
+++ b/llvm/lib/LineEditor/LineEditor.cpp
@@ -294,6 +294,7 @@ void LineEditor::loadHistory() {}
 
 std::optional<std::string> LineEditor::readLine() const {
   ::fprintf(Data->Out, "%s", Prompt.c_str());
+  ::fflush(Data->Out);
 
   std::string Line;
   do {



More information about the llvm-commits mailing list