Skip to content

Commit 14ed297

Browse files
committed
Prevent the preprocessor from replacing std{in,out} with macro
Trying to build on alpine (which uses musl instead of glibc) would break as the preprocessor replaces stdin->(stdin) which fails to compile. After discussion with @ankon he found: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20130506/173524.html
1 parent 5f08b6c commit 14ed297

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

judge/runpipe.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ struct process_t {
162162
// The 0-based index of this process. The 0-th process is the main process.
163163
size_t index;
164164

165-
fd_t stdout = -1; // FD of where the stdout is redirected to.
166-
fd_t stdin = -1; // FD of where the stdin is coming from.
165+
fd_t stdout_fd = -1; // FD of where the stdout is redirected to.
166+
fd_t stdin_fd = -1; // FD of where the stdin is coming from.
167167

168168
// If the proxy is active (i.e. -o is provided), these are the file
169169
// descriptors for its communication.
@@ -231,7 +231,7 @@ struct process_t {
231231

232232
// Fork and exec the child process, redirecting its standard I/O.
233233
void spawn() {
234-
fd_t stdio[3] = {stdin, stdout, FDREDIR_NONE};
234+
fd_t stdio[3] = {stdin_fd, stdout_fd, FDREDIR_NONE};
235235

236236
vector<const char *> argv(args.size());
237237
for (size_t i = 0; i < args.size(); i++) {
@@ -244,8 +244,8 @@ struct process_t {
244244
logmsg(LOG_DEBUG, "started #%ld, pid %d", index, pid);
245245
// Do not leak these file descriptors, otherwise we cannot detect if the
246246
// process has closed stdout.
247-
close(stdin);
248-
close(stdout);
247+
close(stdin_fd);
248+
close(stdout_fd);
249249
}
250250

251251
// Function called when the process exits.
@@ -641,22 +641,22 @@ struct state_t {
641641
tie(read_end, write_end) = make_pipe();
642642
logmsg(LOG_DEBUG, "setting up pipe #%ld (fd %d) -> proxy (fd %d)", i,
643643
write_end, read_end);
644-
process.stdout = write_end;
644+
process.stdout_fd = write_end;
645645
process.process_to_proxy = read_end;
646646
set_non_blocking(process.process_to_proxy);
647647

648648
tie(read_end, write_end) = make_pipe();
649649
logmsg(LOG_DEBUG, "setting up pipe proxy (fd %d) -> #%ld (fd %d)",
650650
write_end, j, read_end);
651651
other.proxy_to_process = write_end;
652-
other.stdin = read_end;
652+
other.stdin_fd = read_end;
653653
} else {
654654
// No proxy: direct communication.
655655
tie(read_end, write_end) = make_pipe();
656656
logmsg(LOG_DEBUG, "setting up pipe #%ld (fd %d) -> #%ld (fd %d)", i,
657657
write_end, j, read_end);
658-
process.stdout = write_end;
659-
other.stdin = read_end;
658+
process.stdout_fd = write_end;
659+
other.stdin_fd = read_end;
660660
}
661661
}
662662
}

0 commit comments

Comments
 (0)