2016-04-20 10:49:15 +08:00
|
|
|
|
// Functions used for implementing the ulimit builtin.
|
2016-05-19 06:30:21 +08:00
|
|
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
|
|
2005-10-15 06:33:01 +08:00
|
|
|
|
#include <errno.h>
|
2016-11-22 13:09:53 +08:00
|
|
|
|
#include <stddef.h>
|
2016-04-20 10:49:15 +08:00
|
|
|
|
#include <sys/resource.h>
|
2005-10-15 06:33:01 +08:00
|
|
|
|
|
|
|
|
|
#include "builtin.h"
|
|
|
|
|
#include "common.h"
|
2016-04-20 10:49:15 +08:00
|
|
|
|
#include "fallback.h" // IWYU pragma: keep
|
2016-04-21 14:00:54 +08:00
|
|
|
|
#include "io.h"
|
2016-04-20 10:49:15 +08:00
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "wgetopt.h"
|
2016-04-21 14:00:54 +08:00
|
|
|
|
#include "wutil.h" // IWYU pragma: keep
|
2006-07-20 06:55:49 +08:00
|
|
|
|
|
2016-04-21 14:00:54 +08:00
|
|
|
|
class parser_t;
|
2005-10-15 06:33:01 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Struct describing a resource limit.
|
|
|
|
|
struct resource_t {
|
|
|
|
|
int resource; // resource ID
|
|
|
|
|
const wchar_t *desc; // description of resource
|
|
|
|
|
wchar_t switch_char; // switch used on commandline to specify resource
|
|
|
|
|
int multiplier; // the implicit multiplier used when setting getting values
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Array of resource_t structs, describing all known resource types.
|
|
|
|
|
static const struct resource_t resource_arr[] = {
|
|
|
|
|
{RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024},
|
|
|
|
|
{RLIMIT_DATA, L"Maximum size of a process’s data segment", L'd', 1024},
|
|
|
|
|
{RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f', 1024},
|
2006-05-19 23:14:43 +08:00
|
|
|
|
#ifdef RLIMIT_MEMLOCK
|
2016-04-20 10:49:15 +08:00
|
|
|
|
{RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l', 1024},
|
2005-11-24 19:13:21 +08:00
|
|
|
|
#endif
|
2006-05-19 23:14:43 +08:00
|
|
|
|
#ifdef RLIMIT_RSS
|
2016-04-20 10:49:15 +08:00
|
|
|
|
{RLIMIT_RSS, L"Maximum resident set size", L'm', 1024},
|
2005-11-24 19:13:21 +08:00
|
|
|
|
#endif
|
2016-04-20 10:49:15 +08:00
|
|
|
|
{RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n', 1},
|
|
|
|
|
{RLIMIT_STACK, L"Maximum stack size", L's', 1024},
|
|
|
|
|
{RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't', 1},
|
2006-05-19 23:14:43 +08:00
|
|
|
|
#ifdef RLIMIT_NPROC
|
2016-04-20 10:49:15 +08:00
|
|
|
|
{RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u', 1},
|
2005-11-24 19:13:21 +08:00
|
|
|
|
#endif
|
2006-05-19 23:14:43 +08:00
|
|
|
|
#ifdef RLIMIT_AS
|
2016-04-20 10:49:15 +08:00
|
|
|
|
{RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v', 1024},
|
2005-10-17 21:36:57 +08:00
|
|
|
|
#endif
|
2016-04-20 10:49:15 +08:00
|
|
|
|
{0, 0, 0, 0}};
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Get the implicit multiplication factor for the specified resource limit.
|
|
|
|
|
static int get_multiplier(int what) {
|
|
|
|
|
for (int i = 0; resource_arr[i].desc; i++) {
|
|
|
|
|
if (resource_arr[i].resource == what) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
return resource_arr[i].multiplier;
|
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
}
|
2012-11-19 08:30:30 +08:00
|
|
|
|
return -1;
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Return the value for the specified resource limit. This function does _not_ multiply the limit
|
|
|
|
|
/// value by the multiplier constant used by the commandline ulimit.
|
|
|
|
|
static rlim_t get(int resource, int hard) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
struct rlimit ls;
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2012-11-19 08:30:30 +08:00
|
|
|
|
getrlimit(resource, &ls);
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
return hard ? ls.rlim_max : ls.rlim_cur;
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Print the value of the specified resource limit.
|
|
|
|
|
static void print(int resource, int hard, io_streams_t &streams) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
rlim_t l = get(resource, hard);
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2012-11-19 08:30:30 +08:00
|
|
|
|
if (l == RLIM_INFINITY)
|
2015-09-22 02:24:49 +08:00
|
|
|
|
streams.out.append(L"unlimited\n");
|
2012-11-19 08:30:30 +08:00
|
|
|
|
else
|
2016-04-20 10:49:15 +08:00
|
|
|
|
streams.out.append_format(L"%d\n", l / get_multiplier(resource));
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Print values of all resource limits.
|
|
|
|
|
static void print_all(int hard, io_streams_t &streams) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
int i;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
int w = 0;
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
for (i = 0; resource_arr[i].desc; i++) {
|
|
|
|
|
w = maxi(w, fish_wcswidth(resource_arr[i].desc));
|
2012-11-19 08:30:30 +08:00
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
for (i = 0; resource_arr[i].desc; i++) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
struct rlimit ls;
|
|
|
|
|
rlim_t l;
|
|
|
|
|
getrlimit(resource_arr[i].resource, &ls);
|
2016-04-20 10:49:15 +08:00
|
|
|
|
l = hard ? ls.rlim_max : ls.rlim_cur;
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
const wchar_t *unit =
|
|
|
|
|
((resource_arr[i].resource == RLIMIT_CPU)
|
|
|
|
|
? L"(seconds, "
|
|
|
|
|
: (get_multiplier(resource_arr[i].resource) == 1 ? L"(" : L"(kB, "));
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
streams.out.append_format(L"%-*ls %10ls-%lc) ", w, resource_arr[i].desc, unit,
|
|
|
|
|
resource_arr[i].switch_char);
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
if (l == RLIM_INFINITY) {
|
2015-09-22 02:24:49 +08:00
|
|
|
|
streams.out.append(L"unlimited\n");
|
2016-04-20 10:49:15 +08:00
|
|
|
|
} else {
|
|
|
|
|
streams.out.append_format(L"%d\n", l / get_multiplier(resource_arr[i].resource));
|
2012-11-19 08:30:30 +08:00
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
}
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Returns the description for the specified resource limit.
|
|
|
|
|
static const wchar_t *get_desc(int what) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
int i;
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
for (i = 0; resource_arr[i].desc; i++) {
|
|
|
|
|
if (resource_arr[i].resource == what) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
return resource_arr[i].desc;
|
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
}
|
2012-11-19 08:30:30 +08:00
|
|
|
|
return L"Not a resource";
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// Set the new value of the specified resource limit. This function does _not_ multiply the limit
|
|
|
|
|
// value by the multiplier constant used by the commandline ulimit.
|
2016-11-22 13:09:53 +08:00
|
|
|
|
static int set_limit(int resource, int hard, int soft, rlim_t value, io_streams_t &streams) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
struct rlimit ls;
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-11-22 13:09:53 +08:00
|
|
|
|
getrlimit(resource, &ls);
|
|
|
|
|
if (hard) ls.rlim_max = value;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
if (soft) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
ls.rlim_cur = value;
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
// Do not attempt to set the soft limit higher than the hard limit.
|
2012-11-19 08:30:30 +08:00
|
|
|
|
if ((value == RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY) ||
|
2016-04-20 10:49:15 +08:00
|
|
|
|
(value != RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY && value > ls.rlim_max)) {
|
2012-11-19 08:30:30 +08:00
|
|
|
|
ls.rlim_cur = ls.rlim_max;
|
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
if (setrlimit(resource, &ls)) {
|
2016-11-22 13:09:53 +08:00
|
|
|
|
if (errno == EPERM) {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
streams.err.append_format(
|
|
|
|
|
L"ulimit: Permission denied when changing resource of type '%ls'\n",
|
|
|
|
|
get_desc(resource));
|
2016-11-22 13:09:53 +08:00
|
|
|
|
} else {
|
2015-09-22 02:24:49 +08:00
|
|
|
|
builtin_wperror(L"ulimit", streams);
|
2016-11-22 13:09:53 +08:00
|
|
|
|
}
|
2017-05-04 15:18:02 +08:00
|
|
|
|
return STATUS_CMD_ERROR;
|
2012-11-19 08:30:30 +08:00
|
|
|
|
}
|
2017-05-04 15:18:02 +08:00
|
|
|
|
return STATUS_CMD_OK;
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
/// The ulimit builtin, used for setting resource limits.
|
|
|
|
|
int builtin_ulimit(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
2016-11-22 13:09:53 +08:00
|
|
|
|
wchar_t *cmd = argv[0];
|
2012-11-19 08:30:30 +08:00
|
|
|
|
int argc = builtin_count_args(argv);
|
2016-11-22 13:09:53 +08:00
|
|
|
|
bool report_all = false;
|
|
|
|
|
bool hard = false;
|
|
|
|
|
bool soft = false;
|
|
|
|
|
int what = RLIMIT_FSIZE;
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2017-06-11 03:30:09 +08:00
|
|
|
|
static const wchar_t *short_options = L":HSacdflmnstuvh";
|
|
|
|
|
static const struct woption long_options[] = {
|
|
|
|
|
{L"all", no_argument, NULL, 'a'},
|
|
|
|
|
{L"hard", no_argument, NULL, 'H'},
|
|
|
|
|
{L"soft", no_argument, NULL, 'S'},
|
|
|
|
|
{L"core-size", no_argument, NULL, 'c'},
|
|
|
|
|
{L"data-size", no_argument, NULL, 'd'},
|
|
|
|
|
{L"file-size", no_argument, NULL, 'f'},
|
|
|
|
|
{L"lock-size", no_argument, NULL, 'l'},
|
|
|
|
|
{L"resident-set-size", no_argument, NULL, 'm'},
|
|
|
|
|
{L"file-descriptor-count", no_argument, NULL, 'n'},
|
|
|
|
|
{L"stack-size", no_argument, NULL, 's'},
|
|
|
|
|
{L"cpu-time", no_argument, NULL, 't'},
|
|
|
|
|
{L"process-count", no_argument, NULL, 'u'},
|
|
|
|
|
{L"virtual-memory-size", no_argument, NULL, 'v'},
|
|
|
|
|
{L"help", no_argument, NULL, 'h'},
|
|
|
|
|
{NULL, 0, NULL, 0}};
|
2016-11-22 13:09:53 +08:00
|
|
|
|
|
|
|
|
|
int opt;
|
|
|
|
|
wgetopter_t w;
|
|
|
|
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
switch (opt) {
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'a': {
|
|
|
|
|
report_all = true;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'H': {
|
|
|
|
|
hard = true;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'S': {
|
|
|
|
|
soft = true;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'c': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_CORE;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'd': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_DATA;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'f': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_FSIZE;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2006-05-26 19:19:34 +08:00
|
|
|
|
#ifdef RLIMIT_MEMLOCK
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'l': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_MEMLOCK;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2005-11-24 19:13:21 +08:00
|
|
|
|
#endif
|
2012-11-18 18:23:22 +08:00
|
|
|
|
#ifdef RLIMIT_RSS
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'm': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_RSS;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2005-11-24 19:13:21 +08:00
|
|
|
|
#endif
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'n': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_NOFILE;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 's': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_STACK;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 't': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_CPU;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
#ifdef RLIMIT_NPROC
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'u': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_NPROC;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2005-11-24 19:13:21 +08:00
|
|
|
|
#endif
|
2012-11-18 18:23:22 +08:00
|
|
|
|
#ifdef RLIMIT_AS
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'v': {
|
2016-04-20 10:49:15 +08:00
|
|
|
|
what = RLIMIT_AS;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
break;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2005-10-17 21:36:57 +08:00
|
|
|
|
#endif
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case 'h': {
|
|
|
|
|
builtin_print_help(parser, streams, cmd, streams.out);
|
2017-05-05 12:35:41 +08:00
|
|
|
|
return STATUS_CMD_OK;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
case ':': {
|
2017-07-02 05:03:47 +08:00
|
|
|
|
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
2017-05-05 12:35:41 +08:00
|
|
|
|
return STATUS_INVALID_ARGS;
|
2016-11-22 13:09:53 +08:00
|
|
|
|
}
|
|
|
|
|
case '?': {
|
|
|
|
|
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1]);
|
2017-05-05 12:35:41 +08:00
|
|
|
|
return STATUS_INVALID_ARGS;
|
2016-04-20 10:49:15 +08:00
|
|
|
|
}
|
2016-10-30 08:25:48 +08:00
|
|
|
|
default: {
|
2016-11-22 13:09:53 +08:00
|
|
|
|
DIE("unexpected retval from wgetopt_long");
|
2016-10-30 08:25:48 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-11-19 08:30:30 +08:00
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 10:49:15 +08:00
|
|
|
|
if (report_all) {
|
2016-11-22 13:09:53 +08:00
|
|
|
|
print_all(hard, streams);
|
2017-05-04 15:18:02 +08:00
|
|
|
|
return STATUS_CMD_OK;
|
2012-11-19 08:30:30 +08:00
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
|
2016-10-23 11:32:25 +08:00
|
|
|
|
int arg_count = argc - w.woptind;
|
|
|
|
|
if (arg_count == 0) {
|
|
|
|
|
// Show current limit value.
|
|
|
|
|
print(what, hard, streams);
|
2017-05-04 15:18:02 +08:00
|
|
|
|
return STATUS_CMD_OK;
|
2016-11-22 13:09:53 +08:00
|
|
|
|
} else if (arg_count != 1) {
|
|
|
|
|
streams.err.append_format(BUILTIN_ERR_TOO_MANY_ARGUMENTS, cmd);
|
|
|
|
|
builtin_print_help(parser, streams, cmd, streams.err);
|
2017-05-05 12:35:41 +08:00
|
|
|
|
return STATUS_INVALID_ARGS;
|
2016-11-22 13:09:53 +08:00
|
|
|
|
}
|
2016-10-23 11:32:25 +08:00
|
|
|
|
|
2016-11-22 13:09:53 +08:00
|
|
|
|
// Change current limit value.
|
|
|
|
|
if (!hard && !soft) {
|
|
|
|
|
// Set both hard and soft limits if neither was specified.
|
|
|
|
|
hard = soft = true;
|
|
|
|
|
}
|
2012-11-19 16:31:03 +08:00
|
|
|
|
|
2016-11-22 13:09:53 +08:00
|
|
|
|
rlim_t new_limit;
|
|
|
|
|
if (*argv[w.woptind] == L'\0') {
|
|
|
|
|
streams.err.append_format(_(L"%ls: New limit cannot be an empty string\n"), cmd);
|
|
|
|
|
builtin_print_help(parser, streams, cmd, streams.err);
|
2017-05-05 12:35:41 +08:00
|
|
|
|
return STATUS_INVALID_ARGS;
|
2016-11-22 13:09:53 +08:00
|
|
|
|
} else if (wcscasecmp(argv[w.woptind], L"unlimited") == 0) {
|
|
|
|
|
new_limit = RLIM_INFINITY;
|
|
|
|
|
} else if (wcscasecmp(argv[w.woptind], L"hard") == 0) {
|
|
|
|
|
new_limit = get(what, 1);
|
|
|
|
|
} else if (wcscasecmp(argv[w.woptind], L"soft") == 0) {
|
|
|
|
|
new_limit = get(what, soft);
|
|
|
|
|
} else {
|
2016-11-23 12:24:03 +08:00
|
|
|
|
new_limit = fish_wcstol(argv[w.woptind]);
|
|
|
|
|
if (errno) {
|
2016-11-22 13:09:53 +08:00
|
|
|
|
streams.err.append_format(_(L"%ls: Invalid limit '%ls'\n"), cmd, argv[w.woptind]);
|
|
|
|
|
builtin_print_help(parser, streams, cmd, streams.err);
|
2017-05-05 12:35:41 +08:00
|
|
|
|
return STATUS_INVALID_ARGS;
|
2012-11-19 16:31:03 +08:00
|
|
|
|
}
|
2016-11-22 13:09:53 +08:00
|
|
|
|
new_limit *= get_multiplier(what);
|
2012-11-19 08:30:30 +08:00
|
|
|
|
}
|
2016-10-23 11:32:25 +08:00
|
|
|
|
|
2016-11-22 13:09:53 +08:00
|
|
|
|
return set_limit(what, hard, soft, new_limit, streams);
|
2005-10-15 06:33:01 +08:00
|
|
|
|
}
|