Add getrlimit(3) and setrlimit(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2013-08-31 00:12:03 +02:00
parent 13f09cc515
commit 7a5e549612
4 changed files with 70 additions and 0 deletions

View File

@ -309,8 +309,10 @@ sys/mman/mprotect.o \
sys/mman/munmap.o \
sys/readdirents/readdirents.o \
sys/resource/getpriority.o \
sys/resource/getrlimit.o \
sys/resource/prlimit.o \
sys/resource/setpriority.o \
sys/resource/setrlimit.o \
sys/select/select.o \
sys/socket/accept4.o \
sys/socket/accept.o \

View File

@ -34,8 +34,10 @@ __BEGIN_DECLS
@include(pid_t.h)
int getpriority(int, id_t);
int getrlimit(int, struct rlimit*);
int prlimit(pid_t, int, const struct rlimit*, struct rlimit*);
int setpriority(int, id_t, int);
int setrlimit(int, const struct rlimit*);
__END_DECLS

View File

@ -0,0 +1,33 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
sys/resource/getrlimit.cpp
Get the resource limits of the current process.
*******************************************************************************/
#include <sys/resource.h>
#include <sys/syscall.h>
#include <stddef.h>
extern "C" int getrlimit(int resource, struct rlimit* limit)
{
return prlimit(0, resource, NULL, limit);
}

View File

@ -0,0 +1,33 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
sys/resource/setrlimit.cpp
Set the resource limits of the current process.
*******************************************************************************/
#include <sys/resource.h>
#include <sys/syscall.h>
#include <stddef.h>
extern "C" int setrlimit(int resource, const struct rlimit* limit)
{
return prlimit(0, resource, limit, NULL);
}