Skip to content

Commit b207b1f

Browse files
author
kr-2003
committed
redirections in launchExecutor
1 parent fbe4344 commit b207b1f

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

clang/include/clang/Interpreter/RemoteJITUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
#include <cstdint>
2424
#include <memory>
2525
#include <string>
26+
#include <unistd.h>
2627

2728
llvm::Expected<std::unique_ptr<llvm::orc::SimpleRemoteEPC>>
2829
launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,
29-
llvm::StringRef SlabAllocateSizeString, int stdin_fd = 0, int stdout_fd = 1, int stderr_fd = 2);
30+
llvm::StringRef SlabAllocateSizeString, int stdin_fd = STDIN_FILENO, int stdout_fd = STDOUT_FILENO, int stderr_fd = STDERR_FILENO);
3031

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

clang/lib/Interpreter/RemoteJITUtils.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,20 @@ launchExecutor(StringRef ExecutablePath, bool UseSharedMemory,
136136
close(ToExecutor[WriteEnd]);
137137
close(FromExecutor[ReadEnd]);
138138

139-
if (stdin_fd != 0) {
139+
if (stdin_fd != STDIN_FILENO) {
140140
dup2(stdin_fd, STDIN_FILENO);
141-
if (stdin_fd != STDIN_FILENO)
142-
close(stdin_fd);
141+
close(stdin_fd);
143142
}
144143

145-
if (stdout_fd != 1) {
144+
if (stdout_fd != STDOUT_FILENO) {
146145
dup2(stdout_fd, STDOUT_FILENO);
147-
if (stdout_fd != STDOUT_FILENO)
148-
close(stdout_fd);
149-
146+
close(stdout_fd);
150147
setvbuf(stdout, NULL, _IONBF, 0);
151148
}
152149

153-
if (stderr_fd != 2) {
150+
if (stderr_fd != STDERR_FILENO) {
154151
dup2(stderr_fd, STDERR_FILENO);
155-
if (stderr_fd != STDERR_FILENO)
156-
close(stderr_fd);
157-
152+
close(stderr_fd);
158153
setvbuf(stderr, NULL, _IONBF, 0);
159154
}
160155

0 commit comments

Comments
 (0)