== SYNOPSIS
-*prlimit* [options] [**--**_resource_[**=**_limits_]] [*--pid* _PID_]
+*prlimit* [options] [**--**_resource_[**=**_limits_]] [*--pid* _PID_[:_inode_]]
*prlimit* [options] [**--**_resource_[**=**_limits_]] _command_ [_argument_...]
*-o*, *--output* _list_::
Define the output columns to use. If no output arrangement is specified, then a default set is used. Use *--help* to get a list of all supported columns.
-*-p*, *--pid* _PID_::
-Specify the process ID. Without this option (and without a _command_),
-the running process will be used.
+*-p*, *--pid* _PID_[:_inode_]::
+Specify the process ID. Without this option (and without a _command_), the running process will be used.
+The _inode_ uniquely identifies the process identity in the pidfs. To retrieve a process's inode number you can use the *getino*(1) utility.
*--raw*::
Use the raw output format.
== SEE ALSO
*ulimit*(1p),
-*prlimit*(2)
+*prlimit*(2),
+*getino*(1)
include::man-common/bugreports.adoc[]
#include "closestream.h"
#include "path.h"
#include "pathnames.h"
+#include "pidutils.h"
+#include "pidfd-utils.h"
#ifndef RLIMIT_RTTIME
# define RLIMIT_RTTIME 15
{
FILE *out = stdout;
size_t i;
+ char *pid_arg = NULL;
+
+#ifdef USE_PIDFD_INO_SUPPORT
+ pid_arg = "PID[:inode]";
+#else
+ pid_arg = "PID";
+#endif
fputs(USAGE_HEADER, out);
fprintf(out,
- _(" %s [options] [--<resource>=<limit>] [-p PID]\n"), program_invocation_short_name);
+ _(" %s [options] [--<resource>=<limit>] [-p %s]\n"), program_invocation_short_name, pid_arg);
fprintf(out,
_(" %s [options] [--<resource>=<limit>] COMMAND\n"), program_invocation_short_name);
return 0;
}
+static int parse_pid_str(char *pidstr, pid_t *pidnum)
+{
+ int pfd = -1;
+ uint64_t pidfd_ino = 0;
+
+ ul_parse_pid_str_or_err(pidstr, pidnum, &pidfd_ino);
+ if (pidfd_ino)
+ pfd = ul_get_valid_pidfd_or_err(*pidnum, pidfd_ino);
+
+ return pfd;
+}
+
int main(int argc, char **argv)
{
- int opt;
+ int opt, pid_fd = -1;
struct list_head lims;
enum {
case 'p':
if (pid)
errx(EXIT_FAILURE, _("option --pid may be specified only once"));
- pid = strtopid_or_err(optarg, _("invalid PID argument"));
+
+ pid_fd = parse_pid_str(optarg, &pid);
break;
case 'o':
ncolumns = string_to_idarray(optarg,
errexec(argv[optind]);
}
+ if (pid_fd >= 0)
+ close(pid_fd);
return EXIT_SUCCESS;
}