From 90c4145a81f77dbe06b1866f3b4296dccb4e0c3d Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Thu, 22 Aug 2024 20:23:13 +0300 Subject: [PATCH] Add closefrom declarations for freebsd, glibc, and, openbsd Signed-off-by: Andrei Horodniceanu --- druntime/src/core/sys/freebsd/unistd.d | 2 ++ druntime/src/core/sys/linux/unistd.d | 4 ++++ druntime/src/core/sys/openbsd/unistd.d | 2 ++ 3 files changed, 8 insertions(+) diff --git a/druntime/src/core/sys/freebsd/unistd.d b/druntime/src/core/sys/freebsd/unistd.d index 493cda1c8c9f..ebb7afa2726c 100644 --- a/druntime/src/core/sys/freebsd/unistd.d +++ b/druntime/src/core/sys/freebsd/unistd.d @@ -17,3 +17,5 @@ extern(C): nothrow: int getosreldate() pure @trusted; + +void closefrom(int); diff --git a/druntime/src/core/sys/linux/unistd.d b/druntime/src/core/sys/linux/unistd.d index faa226cf407c..548870268dbf 100644 --- a/druntime/src/core/sys/linux/unistd.d +++ b/druntime/src/core/sys/linux/unistd.d @@ -5,6 +5,7 @@ public import core.sys.posix.unistd; version (linux): extern(C): nothrow: +@nogc: // Additional seek constants for sparse file handling // from Linux's unistd.h, stdio.h, and linux/fs.h @@ -21,3 +22,6 @@ char* getpass(const(char)* prompt); // Exit all threads in a process void exit_group(int status); + +/// Close all open file descriptors greater or equal to `lowfd` +void closefrom(int lowfd); diff --git a/druntime/src/core/sys/openbsd/unistd.d b/druntime/src/core/sys/openbsd/unistd.d index 4232c0360497..9618543d8da8 100644 --- a/druntime/src/core/sys/openbsd/unistd.d +++ b/druntime/src/core/sys/openbsd/unistd.d @@ -19,3 +19,5 @@ int getthrname(pid_t, char*, size_t); int pledge(const scope char*, const scope char*); int setthrname(pid_t, const scope char*); int unveil(const scope char*, const scope char*); + +int closefrom(int);