LibC: Implement getdtablesize()

This commit is contained in:
Jelle Raaijmakers 2022-03-29 22:47:06 +02:00 committed by Linus Groh
parent 8fee285d72
commit cf1baddb67
Notes: sideshowbarker 2024-07-17 16:33:03 +09:00
2 changed files with 10 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
@ -980,4 +981,12 @@ int chroot(const char* path)
dbgln("FIXME: chroot(\"{}\")", path);
return -1;
}
// https://pubs.opengroup.org/onlinepubs/7908799/xsh/getdtablesize.html
int getdtablesize()
{
rlimit dtablesize;
int rc = getrlimit(RLIMIT_NOFILE, &dtablesize);
__RETURN_WITH_ERRNO(rc, dtablesize.rlim_cur, rc);
}
}

View File

@ -118,6 +118,7 @@ int unveil(const char* path, const char* permissions);
char* getpass(const char* prompt);
int pause(void);
int chroot(const char*);
int getdtablesize(void);
enum {
_PC_NAME_MAX,