From 4945adc1fffd0641a0a273bcedeb52f3bba653bf Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 20 Oct 2025 08:36:07 +0000 Subject: More sysdeps --- configure | 3 +++ src/sysdeps/trykevent.c | 19 +++++++++++++++++++ src/sysdeps/trypidfd_open.c | 9 +++++++++ src/sysdeps/tryprsetchildsubreaper.c | 12 ++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 src/sysdeps/trykevent.c create mode 100644 src/sysdeps/trypidfd_open.c create mode 100644 src/sysdeps/tryprsetchildsubreaper.c diff --git a/configure b/configure index 53b5194..9f89a61 100755 --- a/configure +++ b/configure @@ -717,6 +717,9 @@ choose cl kernprocpathname 'the KERN_PROC_PATHNAME sysctl' choose cl _nsgetexecutablepath '_NSGetExecutablePath()' choose cl getexecname 'getexecname()' choose cl dladdr 'dladdr()' +choose c pidfd_open 'pidfd_open()' +choose cl kevent 'kevent()' +choose cl prsetchildsubreaper 'PR_SET_CHILD_SUBREAPER' # Here are the evil irreducible run-time sysdeps. choose clr devurandom '/dev/urandom' diff --git a/src/sysdeps/trykevent.c b/src/sysdeps/trykevent.c new file mode 100644 index 0000000..8c54f4d --- /dev/null +++ b/src/sysdeps/trykevent.c @@ -0,0 +1,19 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#include +#include +#include +#include + +int main (void) +{ + int q = kqueue() ; + struct kevent ke ; + struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 } ; + EV_SET(&ke, getpid(), EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, 0) ; + kevent(q, &ke, 1, &ke, 1, &ts) ; + return 0 ; +} diff --git a/src/sysdeps/trypidfd_open.c b/src/sysdeps/trypidfd_open.c new file mode 100644 index 0000000..8840742 --- /dev/null +++ b/src/sysdeps/trypidfd_open.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#include +#include + +static long a = SYS_pidfd_open ; diff --git a/src/sysdeps/tryprsetchildsubreaper.c b/src/sysdeps/tryprsetchildsubreaper.c new file mode 100644 index 0000000..6a65691 --- /dev/null +++ b/src/sysdeps/tryprsetchildsubreaper.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#include + +int main (void) +{ + prctl(PR_SET_CHILD_SUBREAPER, 1) ; + return 0 ; +} -- cgit v1.3.1