home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
SETRLIMI.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
1KB
|
91 lines
/* get/set resource limits */
/* written by Eric R. Smith and placed in the public domain */
#include <time.h>
#include <types.h>
#include <resource.h>
#include <mintbind.h>
#include <errno.h>
extern int __mint;
int
setrlimit(kind, rl)
int kind;
struct rlimit *rl;
{
unsigned long limit;
long r;
int mode;
if (!__mint) {
errno = EINVAL;
return -1;
}
limit = rl->rlim_cur;
if (limit >= RLIM_INFINITY)
limit = 0;
else if (limit == 0)
limit = 1;
switch(kind) {
case RLIMIT_CPU:
mode = 1; break;
case RLIMIT_RSS:
mode = 2; break;
case RLIMIT_DATA:
mode = 3; break;
default:
errno = EINVAL;
return -1;
}
r = Psetlimit(mode, limit);
if (r < 0) {
errno = -r;
return -1;
}
return 0;
}
int
getrlimit(kind, rl)
int kind;
struct rlimit *rl;
{
long limit;
int mode;
if (!__mint) {
errno = EINVAL;
return -1;
}
switch(kind) {
case RLIMIT_CPU:
mode = 1;
break;
case RLIMIT_RSS:
mode = 2;
break;
case RLIMIT_DATA:
mode = 3;
break;
default:
errno = EINVAL;
return -1;
}
limit = Psetlimit(mode, -1L);
if (limit < 0) {
errno = -limit;
return -1;
}
if (limit == 0)
limit = RLIM_INFINITY;
rl->rlim_cur = limit;
rl->rlim_max = RLIM_INFINITY;
return 0;
}