mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-20 11:51:24 +01:00
27566: add ulimit -c hard and immediate return on argument error
This commit is contained in:
parent
de4dac8874
commit
f80bc2b5f6
3 changed files with 35 additions and 14 deletions
|
@ -1,5 +1,8 @@
|
||||||
2010-01-05 Peter Stephenson <pws@csr.com>
|
2010-01-05 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 27566: Src/Builtins/rlimits.c: add ulimit -c hard and immediate
|
||||||
|
return on argument error
|
||||||
|
|
||||||
* 27565: Src/Builtins/rlimits.c: ulimit didn't sanity check
|
* 27565: Src/Builtins/rlimits.c: ulimit didn't sanity check
|
||||||
numeric arguments.
|
numeric arguments.
|
||||||
|
|
||||||
|
@ -12542,5 +12545,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4853 $
|
* $Revision: 1.4854 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -1710,13 +1710,18 @@ cindex(limits, resource)
|
||||||
item(tt(ulimit) [ [ tt(-SHacdfilmnpqstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
|
item(tt(ulimit) [ [ tt(-SHacdfilmnpqstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
|
||||||
Set or display resource limits of the shell and the processes started by
|
Set or display resource limits of the shell and the processes started by
|
||||||
the shell. The value of var(limit) can be a number in the unit specified
|
the shell. The value of var(limit) can be a number in the unit specified
|
||||||
below or the value `tt(unlimited)'. By default, only soft limits are
|
below or one of the values `tt(unlimited)', which removes the limit on the
|
||||||
manipulated. If the tt(-H) flag is given use
|
resource, or `tt(hard)', which uses the current value of the hard limit on
|
||||||
hard limits instead of soft limits. If the tt(-S) flag is given
|
the resource.
|
||||||
together with the tt(-H) flag set both hard and soft limits. If no
|
|
||||||
options are used, the file size limit (tt(-f)) is assumed. If
|
By default, only soft limits are manipulated. If the tt(-H) flag
|
||||||
var(limit) is omitted the current value of the specified resources are
|
is given use hard limits instead of soft limits. If the tt(-S) flag is given
|
||||||
printed. When more than one resource values are printed the limit name and
|
together with the tt(-H) flag set both hard and soft limits.
|
||||||
|
|
||||||
|
If no options are used, the file size limit (tt(-f)) is assumed.
|
||||||
|
|
||||||
|
If var(limit) is omitted the current value of the specified resources are
|
||||||
|
printed. When more than one resource value is printed, the limit name and
|
||||||
unit is printed before each value.
|
unit is printed before each value.
|
||||||
|
|
||||||
When looping over multiple resources, the shell will abort immediately if
|
When looping over multiple resources, the shell will abort immediately if
|
||||||
|
|
|
@ -836,11 +836,24 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
|
||||||
/* set limit to specified value */
|
/* set limit to specified value */
|
||||||
rlim_t limit;
|
rlim_t limit;
|
||||||
|
|
||||||
limit = zstrtorlimt(*argv, &eptr, 10);
|
if (!strcmp(*argv, "hard")) {
|
||||||
if (*eptr) {
|
struct rlimit vals;
|
||||||
zwarnnam(name, "invalid number: %s", *argv);
|
|
||||||
ret++;
|
if (getrlimit(res, &vals) < 0)
|
||||||
|
{
|
||||||
|
zwarnnam(name, "can't read limit: %e", errno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
limit = vals.rlim_max;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
limit = zstrtorlimt(*argv, &eptr, 10);
|
||||||
|
if (*eptr) {
|
||||||
|
zwarnnam(name, "invalid number: %s", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/* scale appropriately */
|
/* scale appropriately */
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case RLIMIT_FSIZE:
|
case RLIMIT_FSIZE:
|
||||||
|
@ -870,9 +883,9 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
|
||||||
limit *= 1024;
|
limit *= 1024;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (do_limit(name, res, limit, hard, soft, 1))
|
|
||||||
ret++;
|
|
||||||
}
|
}
|
||||||
|
if (do_limit(name, res, limit, hard, soft, 1))
|
||||||
|
ret++;
|
||||||
} else {
|
} else {
|
||||||
if (do_unlimit(name, res, hard, soft, 1, geteuid()))
|
if (do_unlimit(name, res, hard, soft, 1, geteuid()))
|
||||||
ret++;
|
ret++;
|
||||||
|
|
Loading…
Reference in a new issue