Previously a couple of options were added for making setrlimit(2)
calls after forking, so now we add the rest.
I also discovered an issue in the earlier approach for
handle_limit_arg() and enter(), in that if we were trying to set the
limit to one of the current values, and the current value was
"unlimited", we'd completely skip setting the value, because this
corresponds to RLIM_INFINITY. To fix this, also store an array of
struct rlimit pointers in entry_settings, and only set the pointer
when we've parsed the associated command line option.
Fixes #28.
I changed the man page a little. Due to the number of related
options, I've grouped them together in a table. This helps a lot if
the terminal width is restricted, and also when pasting said output
into a git commit message. I also added a "more info" link to
getrlimit(2) as that describes all of the limits in great detail.
Formatted output from bst(1):
--limit-as <arg> size of virtual memory
--limit-core <arg> maximum size of core files created
--limit-cpu <arg> maximum amount of CPU time in seconds
--limit-data <arg> maximum size of a process's data segment
--limit-fsize <arg> maximum size of files written by the shell
and its children
--limit-locks <arg> maximum number of file locks
--limit-memlock <arg> maximum size a process may lock into memory
--limit-msgqueue <arg> maximum number of bytes in POSIX message
queues
--limit-nice <arg> maximum scheduling priority (`nice')
--limit-nofile <arg> maximum number of open file descriptors
--limit-nproc <arg> maximum number of user processes
--limit-rss <arg> maximum resident set size
--limit-rtprio <arg> maximum real-time scheduling priority
--limit-rttime <arg> limit (in microseconds) of real-time-sched‐
uled CPU time before making a blocking sys‐
tem call
--limit-sigpending <arg> maximum number of pending signals
--limit-stack <arg> maximum stack size
The --limit-<limit> options set the specified hard and soft re‐
source limits based on <arg>.
Format of <arg>:
• Single numerical value: set both hard and soft limits to <arg>.
• Colon-separated hard:soft values.
When either limit is not provided (empty string), use the current
value without trying to make any changes. When neither limit is
provided, this is a special case to set the soft resource limit to
the current hard limit value.
Examples:
--limit-nproc 100 hard=100, soft=100
--limit-nproc 200:100 hard=200, soft=100
--limit-nproc :100 hard=(unchanged), soft=100
--limit-nproc 100: hard=100, soft=(unchanged)
--limit-nproc : hard=(unchanged), soft=(hard limit)
Full details for each limit value can be found in getrlimit(2).
Previously a couple of options were added for making setrlimit(2) calls after forking, so now we add the rest.
I also discovered an issue in the earlier approach for
handle_limit_arg()
andenter()
, in that if we were trying to set the limit to one of the current values, and the current value was "unlimited", we'd completely skip setting the value, because this corresponds toRLIM_INFINITY
. To fix this, also store an array ofstruct rlimit
pointers inentry_settings
, and only set the pointer when we've parsed the associated command line option.Fixes #28.
I changed the man page a little. Due to the number of related options, I've grouped them together in a table. This helps a lot if the terminal width is restricted, and also when pasting said output into a git commit message. I also added a "more info" link to getrlimit(2) as that describes all of the limits in great detail.
Formatted output from bst(1):