summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2020-12-17 12:07:54 +0100
committerDenys Vlasenko2020-12-17 12:07:54 +0100
commit91e330a53fc8052addec941a9e1e6fcd4b68702b (patch)
treeb90a654a45151bf96123d3e0d7971127e1dc1b85 /shell
parent072313162870e9675c3e6f346a804a324a907f93 (diff)
downloadbusybox-91e330a53fc8052addec941a9e1e6fcd4b68702b.zip
busybox-91e330a53fc8052addec941a9e1e6fcd4b68702b.tar.gz
shells: a fix for systems without RLIMIT_NICE
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/shell_common.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c
index dcbe0d1..f95a35e 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -324,12 +324,18 @@ struct limits {
uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */
};
+/* Order of entries matches order in which bash prints "ulimit -a" */
static const struct limits limits_tbl[] ALIGN2 = {
{ RLIMIT_CORE, 9, }, // -c
{ RLIMIT_DATA, 10, }, // -d
+#ifdef RLIMIT_NICE
{ RLIMIT_NICE, 0, }, // -e
- { RLIMIT_FSIZE, 9, }, // -f
#define LIMIT_F_IDX 3
+#else
+/* for example, Hurd */
+#define LIMIT_F_IDX 2
+#endif
+ { RLIMIT_FSIZE, 9, }, // -f
#ifdef RLIMIT_SIGPENDING
{ RLIMIT_SIGPENDING, 0, }, // -i
#endif
@@ -364,13 +370,16 @@ static const struct limits limits_tbl[] ALIGN2 = {
{ RLIMIT_LOCKS, 0, }, // -x
#endif
};
-// bash also shows:
+// 1) bash also shows:
//pipe size (512 bytes, -p) 8
+// 2) RLIMIT_RTTIME ("timeout for RT tasks in us") is not in the table
static const char limits_help[] ALIGN1 =
"core file size (blocks)" // -c
"\0""data seg size (kb)" // -d
+#ifdef RLIMIT_NICE
"\0""scheduling priority" // -e
+#endif
"\0""file size (blocks)" // -f
#ifdef RLIMIT_SIGPENDING
"\0""pending signals" // -i
@@ -410,7 +419,9 @@ static const char limits_help[] ALIGN1 =
static const char limit_chars[] ALIGN1 =
"c"
"d"
+#ifdef RLIMIT_NICE
"e"
+#endif
"f"
#ifdef RLIMIT_SIGPENDING
"i"
@@ -451,7 +462,9 @@ static const char limit_chars[] ALIGN1 =
static const char ulimit_opt_string[] ALIGN1 = "-HSa"
"c::"
"d::"
+#ifdef RLIMIT_NICE
"e::"
+#endif
"f::"
#ifdef RLIMIT_SIGPENDING
"i::"
@@ -668,7 +681,7 @@ shell_builtin_ulimit(char **argv)
if (opt_cnt == 0) {
/* "bare ulimit": treat it as if it was -f */
- getrlimit(limits_tbl[LIMIT_F_IDX].cmd, &limit);
+ getrlimit(RLIMIT_FSIZE, &limit);
printlim(opts, &limit, &limits_tbl[LIMIT_F_IDX]);
}