diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2019-10-11 22:07:46 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2020-01-09 22:52:23 +0100 |
commit | 079fbebb6ab91479107e84e2c81966ca5f157529 (patch) | |
tree | ef3220eb1b9db744d0dd672ba2f3eae87d6cb297 | |
parent | 22f0905b4ac1af125d382440716b97f4e6142676 (diff) |
forkfd/Linux: remove unused code
The detection code for Linux 5.2 and 5.3 went unused. We had it in the
initial commit so it got recorded for posterity, in case someone wants
to detect them (the road not taken).
Change-Id: Ib5d667bf77a740c28d2efffd15cccdff5aa5a622
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
-rw-r--r-- | src/3rdparty/forkfd/forkfd_linux.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/3rdparty/forkfd/forkfd_linux.c b/src/3rdparty/forkfd/forkfd_linux.c index ea587b7ed5..27ab09f748 100644 --- a/src/3rdparty/forkfd/forkfd_linux.c +++ b/src/3rdparty/forkfd/forkfd_linux.c @@ -120,76 +120,8 @@ static int detect_clone_pidfd_support() sys_waitid(P_PIDFD, INT_MAX, NULL, WEXITED|WNOHANG, NULL); return errno == EBADF ? 1 : -1; - -#if 0 - /* Detection methods not used: */ -#ifdef __NR_pidfd_send_signal - /* - * pidfd_send_signal was added at the same time as CLONE_PIDFD, so if this - * system call exists, so does CLONE_PIDFD. We make a system call with a - * file descriptor of -1: if it's supported, we get EBADF; otherwise, the - * typical ENOSYS. - */ - syscall(__NR_pidfd_send_signal, -1, 0, NULL, 0); - return errno == EBADF ? 1 : -1; -#else - /* - * detect kernel CLONE_PIDFD support directly: CLONE_PIDFD | - * CLONE_PARENT_SETTID causes EINVAL on kernel >= 5.2, but on older - * kernels, that combination is ignored. Therefore, if we EINVAL, we know - * that CLONE_PIDFD is supported. - * - * To avoid creating a process unnecessarily, we add CLONE_NEWUTS, which is - * a privileged operation. Therefore, if we're not root, we'll get EPERM. - * If we're root, we need to exit the child process and wait for it on the - * parent. - */ - pid_t pid = sys_clone(CLONE_PIDFD | CLONE_PARENT_SETTID | CLONE_NEWUTS, NULL); - if (pid == -1 && errno == EINVAL) - return 1; - if (pid == 0) - _exit(0); /* Child */ - if (pid > 0) - sys_waitid(P_PID, pid, NULL, WEXITED | __WALL, NULL); /* Parent */ - - return -1; -#endif -#endif // 0 } -#if 0 -/* To be used if waitid's P_PIDFD support gets bumped to 5.4 */ -static pid_t pidfd_to_pid(int pidfd) -{ - static const char pidtext[] = "Pid:\t"; - int fdinfo; - ssize_t ret; - char buf[256]; - char *text, *endpid = NULL; - - snprintf(buf, sizeof(buf), "/proc/self/fdinfo/%d", pidfd); - fdinfo = open(buf, O_RDONLY | O_CLOEXEC); - if (fdinfo < 0) - return fdinfo; - - ret = read(fdinfo, buf, sizeof(buf) - 1); - close(fdinfo); - if (ret < 1) - return ret; - - buf[ret] = '\0'; - text = (char *) memmem(buf, ret, pidtext, sizeof(pidtext) - 1); - if (text == NULL) - return -1; - - text += sizeof(pidtext) - 1; - ret = strtol(text, &endpid, 10); - if (ret < 0 || (endpid && *endpid != '\n')) - return -1; - return ret; -} -#endif - int system_has_forkfd() { return ffd_atomic_load(&system_forkfd_state, FFD_ATOMIC_RELAXED) > 0; |