Skip to content

Commit 2da21ba

Browse files
author
kr-2003
committed
introduced lambda in launchExecutor
1 parent e95962e commit 2da21ba

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

clang/include/clang/Interpreter/RemoteJITUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
llvm::Expected<std::unique_ptr<llvm::orc::SimpleRemoteEPC>>
3636
launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,
3737
llvm::StringRef SlabAllocateSizeString,
38-
int stdin_fd = STDIN_FILENO, int stdout_fd = STDOUT_FILENO,
39-
int stderr_fd = STDERR_FILENO);
38+
std::function<void()> CustomizeFork = nullptr);
4039

4140
/// Create a JITLinkExecutor that connects to the given network address
4241
/// through a TCP socket. A valid NetworkAddress provides hostname and port,

clang/lib/Interpreter/RemoteJITUtils.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ createSharedMemoryManager(SimpleRemoteEPC &SREPC,
9595

9696
Expected<std::unique_ptr<SimpleRemoteEPC>>
9797
launchExecutor(StringRef ExecutablePath, bool UseSharedMemory,
98-
llvm::StringRef SlabAllocateSizeString, int stdin_fd,
99-
int stdout_fd, int stderr_fd) {
98+
llvm::StringRef SlabAllocateSizeString,
99+
std::function<void()> CustomizeFork) {
100100
#ifndef LLVM_ON_UNIX
101101
// FIXME: Add support for Windows.
102102
return make_error<StringError>("-" + ExecutablePath +
@@ -139,22 +139,8 @@ launchExecutor(StringRef ExecutablePath, bool UseSharedMemory,
139139
close(ToExecutor[WriteEnd]);
140140
close(FromExecutor[ReadEnd]);
141141

142-
if (stdin_fd != STDIN_FILENO) {
143-
dup2(stdin_fd, STDIN_FILENO);
144-
close(stdin_fd);
145-
}
146-
147-
if (stdout_fd != STDOUT_FILENO) {
148-
dup2(stdout_fd, STDOUT_FILENO);
149-
close(stdout_fd);
150-
setvbuf(stdout, NULL, _IONBF, 0);
151-
}
152-
153-
if (stderr_fd != STDERR_FILENO) {
154-
dup2(stderr_fd, STDERR_FILENO);
155-
close(stderr_fd);
156-
setvbuf(stderr, NULL, _IONBF, 0);
157-
}
142+
if (CustomizeFork)
143+
CustomizeFork();
158144

159145
// Execute the child process.
160146
std::unique_ptr<char[]> ExecutorPath, FDSpecifier;

0 commit comments

Comments
 (0)