1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:17:35 +00:00

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
2 changed files with 10 additions and 0 deletions

View file

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/resource.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
@ -980,4 +981,12 @@ int chroot(const char* path)
dbgln("FIXME: chroot(\"{}\")", path); dbgln("FIXME: chroot(\"{}\")", path);
return -1; 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); char* getpass(const char* prompt);
int pause(void); int pause(void);
int chroot(const char*); int chroot(const char*);
int getdtablesize(void);
enum { enum {
_PC_NAME_MAX, _PC_NAME_MAX,