-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid pipe2 in support/interactive #148
Comments
The changes in that commit should really be made conditional on Linux, yeah. Some previous discussion in #122. |
Like this: #ifdef _GNU_SOURCE
const int PIPE_SIZE = 1<<20; // 1 MiB (the default max value for an unprivileged user)
#endif
...
#ifdef _GNU_SOURCE
if(pipe2(fd, O_CLOEXEC)) {
perror("pipe failed");
exit(EXIT_FAILURE);
}
if (fcntl(fd[0], F_SETPIPE_SZ, PIPE_SIZE) == -1) {
perror("failed to set pipe size");
}
#else
if(pipe(fd)) {
perror("pipe failed");
exit(EXIT_FAILURE);
}
for(int i = 0; i < 2; i++) {
set_cloexec(fd[i], 1);
}
#endif Not sure which variable to ifdef on. With the above changes, I can cleanly compile this part at least on OS X. (The other issue, apparently also known, is with libchecktestdata.) |
Re “the other issue”: the one-line patch at DOMjudge/checktestdata@470b9e5 does indeed fix libchecktestdata, and with those two changes the whole problemtools suite seems to compile on OS X. (Well, there are some warnings about unused variables in libchecktestdata.) |
@simonlindholm : What’s the preferred way to test for “are we on Linux?” |
Not certain, I guess |
Closed in 9d85d66 |
pipe2
is linux-specific, so thatmake
fails on BSD-based unixes such as OS X.My (limited) understanding is that the flag in the 2nd argument
pipe2(fd, O_CLOEXEC)
inmakepipe
ensures that the pipes are closed upon exit, which can be achieved withfcntl
in a platform-independent way.problemtools/support/interactive/interactive.cc
Line 194 in eb7b607
Linux man page: http://man7.org/linux/man-pages/man2/pipe.2.html
An easy fix is to revert that part of the code to the state before 0d38a8b
The text was updated successfully, but these errors were encountered: