diff options
author | Sami Kerola | 2012-06-15 23:40:49 +0200 |
---|---|---|
committer | Sami Kerola | 2012-06-17 17:59:59 +0200 |
commit | 73e1d7fb02069da6adb7ded1dc630e3c59ac0486 (patch) | |
tree | 541ec15e935288570d48e972f83f56a739ca7e2b /sys-utils/prlimit.c | |
parent | lscpu: use exclusive_option() (diff) | |
download | kernel-qcow2-util-linux-73e1d7fb02069da6adb7ded1dc630e3c59ac0486.tar.gz kernel-qcow2-util-linux-73e1d7fb02069da6adb7ded1dc630e3c59ac0486.tar.xz kernel-qcow2-util-linux-73e1d7fb02069da6adb7ded1dc630e3c59ac0486.zip |
prlimit: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/prlimit.c')
-rw-r--r-- | sys-utils/prlimit.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index 58e189c1f..cd9a96c62 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -34,6 +34,7 @@ #include "strutils.h" #include "list.h" #include "closestream.h" +#include "optutils.h" #ifndef RLIMIT_RTTIME # define RLIMIT_RTTIME 15 @@ -483,6 +484,12 @@ int main(int argc, char **argv) RAW_OPTION, NOHEADINGS_OPTION }; + enum { + EXCL_NONE, + EXCL_COMMAND, + EXCL_PID + }; + int excl_pcom = EXCL_NONE; static const struct option longopts[] = { { "pid", required_argument, NULL, 'p' }, @@ -578,9 +585,7 @@ int main(int argc, char **argv) break; case 'p': - if (pid) /* we only work one pid at a time */ - errx(EXIT_FAILURE, _("only use one PID at a time")); - + exclusive_option(&excl_pcom, EXCL_PID + optind, _("--pid and --pid")); pid = strtos32_or_err(optarg, _("invalid PID argument")); break; case 'h': @@ -611,9 +616,8 @@ int main(int argc, char **argv) } } if (argc > optind && pid) - errx(EXIT_FAILURE, - _("--pid option and COMMAND are mutually exclusive")); - + exclusive_option(&excl_pcom, EXCL_COMMAND, + _("--pid and COMMAND")); if (!ncolumns) { /* default columns */ columns[ncolumns++] = COL_RES; |