summaryrefslogtreecommitdiffstats
path: root/sys-utils/prlimit.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
commit1272be04be0cb803eec87f602edb2e3e6f111aea (patch)
treebce17f6478cdd9f3c4ec3d751135dc42786d6a56 /sys-utils/prlimit.c
parentReleasing progress-linux version 2.39.3-11~progress7.99u1. (diff)
downloadutil-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz
util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--sys-utils/prlimit.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index ca69ccf..57c11fb 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -1,23 +1,15 @@
/*
- * prlimit - get/set process resource limits.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
- * Copyright (C) 2011 Davidlohr Bueso <dave@gnu.org>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (C) 2011 Davidlohr Bueso <dave@gnu.org>
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * prlimit - get/set process resource limits.
*/
-
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
@@ -114,14 +106,14 @@ enum {
/* column names */
struct colinfo {
- const char *name; /* header */
- double whint; /* width hint (N < 1 is in percent of termwidth) */
- int flags; /* SCOLS_FL_* */
- const char *help;
+ const char * const name; /* header */
+ double whint; /* width hint (N < 1 is in percent of termwidth) */
+ int flags; /* SCOLS_FL_* */
+ const char *help;
};
/* columns descriptions */
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
[COL_RES] = { "RESOURCE", 0.25, SCOLS_FL_TRUNC, N_("resource name") },
[COL_HELP] = { "DESCRIPTION", 0.1, SCOLS_FL_TRUNC, N_("resource description")},
[COL_SOFT] = { "SOFT", 0.1, SCOLS_FL_RIGHT, N_("soft limit")},
@@ -179,7 +171,7 @@ static void __attribute__((__noreturn__)) usage(void)
" --raw use the raw output format\n"
" --verbose verbose output\n"
), out);
- printf(USAGE_HELP_OPTIONS(24));
+ fprintf(out, USAGE_HELP_OPTIONS(24));
fputs(_("\nResources:\n"), out);
fputs(_(" -c, --core maximum size of core files created\n"
@@ -209,7 +201,7 @@ static void __attribute__((__noreturn__)) usage(void)
for (i = 0; i < ARRAY_SIZE(infos); i++)
fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help));
- printf(USAGE_MAN_TAIL("prlimit(1)"));
+ fprintf(out, USAGE_MAN_TAIL("prlimit(1)"));
exit(EXIT_SUCCESS);
}
@@ -222,7 +214,7 @@ static inline int get_column_id(int num)
return columns[num];
}
-static inline struct colinfo *get_column_info(unsigned num)
+static inline const struct colinfo *get_column_info(unsigned num)
{
return &infos[ get_column_id(num) ];
}
@@ -314,7 +306,7 @@ static int show_limits(struct list_head *lims)
scols_table_enable_noheadings(table, no_headings);
for (i = 0; i < ncolumns; i++) {
- struct colinfo *col = get_column_info(i);
+ const struct colinfo *col = get_column_info(i);
if (!scols_table_new_column(table, col->name, col->whint, col->flags))
err(EXIT_FAILURE, _("failed to allocate output column"));
@@ -455,8 +447,10 @@ static int get_range(char *str, rlim_t *soft, rlim_t *hard, int *found)
}
*found |= PRLIMIT_SOFT | PRLIMIT_HARD;
- } else /* <value> */
+ } else if (!*end) /* <value> */
*found |= PRLIMIT_SOFT | PRLIMIT_HARD;
+ else
+ return -1;
return 0;
}