meson.build: check for SYS_pidfd_open

This commit is contained in:
Peter Hutterer 2021-06-10 15:12:12 +10:00
parent 18b3efa2ed
commit 14eb43ea86
3 changed files with 9 additions and 0 deletions

View file

@ -475,6 +475,7 @@
#mesondefine HAVE_MEMFD_CREATE
#mesondefine HAVE_GETRANDOM
#mesondefine HAVE_SIGABBREV_NP
#mesondefine HAVE_PIDFD_OPEN
#mesondefine PIPEWIRE_VERSION_MAJOR
#mesondefine PIPEWIRE_VERSION_MINOR

View file

@ -282,6 +282,10 @@ if cc.has_function('sigabbrev_np', prefix : '#include <string.h>', args : [ '-D_
cdata.set('HAVE_SIGABBREV_NP', 1)
endif
if cc.get_define('SYS_pidfd_open', prefix : '#include <syscall.h>') != ''
cdata.set('HAVE_PIDFD_OPEN', 1)
endif
systemd = dependency('systemd', required: get_option('systemd'))
systemd_dep = dependency('libsystemd',required: get_option('systemd'))
if systemd.found() and systemd_dep.found()

View file

@ -812,7 +812,11 @@ static int monitor_test_forked(struct pwtest_test *t, pid_t pid, int read_fds[_F
size_t nevents = 0;
int r;
#if HAVE_PIDFD_OPEN
pidfd = syscall(SYS_pidfd_open, pid, 0);
#else
errno = ENOSYS;
#endif
/* If we don't have pidfd, we use a timerfd to ping us every 20ms */
if (pidfd < 0 && errno == ENOSYS) {
pidfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);