mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
rc: use proper type for storing ulimit values
rc on amd64 stores ulimit values as 32-bit int, but the limits on OpenBSD amd64 can exceed 2^31, so "ulimit -a" shows some values as negative. This is a problem when I want to increase my ulimit but the hard ulimit values are printed as negative.
This commit is contained in:
parent
60f06594cc
commit
019be4481f
1 changed files with 7 additions and 6 deletions
|
@ -58,7 +58,8 @@ eusage(void)
|
||||||
void
|
void
|
||||||
execulimit(void)
|
execulimit(void)
|
||||||
{
|
{
|
||||||
int fd, n, argc, sethard, setsoft, limit;
|
rlim_t n;
|
||||||
|
int fd, argc, sethard, setsoft, limit;
|
||||||
int flag[256];
|
int flag[256];
|
||||||
char **argv, **oargv, *p;
|
char **argv, **oargv, *p;
|
||||||
char *argv0;
|
char *argv0;
|
||||||
|
@ -118,10 +119,10 @@ execulimit(void)
|
||||||
for(p=eargs; *p; p++){
|
for(p=eargs; *p; p++){
|
||||||
getrlimit(rlx[p-eargs], &rl);
|
getrlimit(rlx[p-eargs], &rl);
|
||||||
n = flag['H'] ? rl.rlim_max : rl.rlim_cur;
|
n = flag['H'] ? rl.rlim_max : rl.rlim_cur;
|
||||||
if(n == -1)
|
if(n == RLIM_INFINITY)
|
||||||
fprint(fd, "ulimit -%c unlimited\n", *p);
|
fprint(fd, "ulimit -%c unlimited\n", *p);
|
||||||
else
|
else
|
||||||
fprint(fd, "ulimit -%c %d\n", *p, n);
|
fprint(fd, "ulimit -%c %llud\n", *p, (uvlong)n);
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -132,10 +133,10 @@ execulimit(void)
|
||||||
switch(limit){
|
switch(limit){
|
||||||
case Notset:
|
case Notset:
|
||||||
n = flag['H'] ? rl.rlim_max : rl.rlim_cur;
|
n = flag['H'] ? rl.rlim_max : rl.rlim_cur;
|
||||||
if(n == -1)
|
if(n == RLIM_INFINITY)
|
||||||
fprint(fd, "ulimit -%c unlimited\n", *p);
|
fprint(fd, "ulimit -%c unlimited\n", *p);
|
||||||
else
|
else
|
||||||
fprint(fd, "ulimit -%c %d\n", *p, n);
|
fprint(fd, "ulimit -%c %llud\n", *p, (uvlong)n);
|
||||||
break;
|
break;
|
||||||
case Hard:
|
case Hard:
|
||||||
n = rl.rlim_max;
|
n = rl.rlim_max;
|
||||||
|
@ -144,7 +145,7 @@ execulimit(void)
|
||||||
n = rl.rlim_cur;
|
n = rl.rlim_cur;
|
||||||
goto set;
|
goto set;
|
||||||
case Unlimited:
|
case Unlimited:
|
||||||
n = -1;
|
n = RLIM_INFINITY;
|
||||||
goto set;
|
goto set;
|
||||||
default:
|
default:
|
||||||
n = limit;
|
n = limit;
|
||||||
|
|
Loading…
Reference in a new issue