Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more limits in ulimit #8786

Closed
septatrix opened this issue Mar 14, 2022 · 5 comments · Fixed by #8823
Closed

Expose more limits in ulimit #8786

septatrix opened this issue Mar 14, 2022 · 5 comments · Fixed by #8823
Assignees
Milestone

Comments

@septatrix
Copy link
Contributor

  • Version: 3.3.1
  • OS: Fedora 35, Kernel Version: 5.16.12-200.fc35.x86_64

The bash builtin ulimit (which is also the fallback/command ulimit) exposes many more limits which fish does not show. Some of them might be unique to bash and others seem to have a reason for excluding -p the are quite a few which are missing. The list seems to be eipqrsx

~ $ bash -c "type ulimit && ulimit -a"
ulimit is a shell builtin
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 95584
max locked memory           (kbytes, -l) 8192
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 95584
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited
~ $ type ulimit && ulimit -a
ulimit is a builtin
Maximum size of core files created                           (kB, -c) unlimited
Maximum size of a process’s data segment                     (kB, -d) unlimited
Maximum size of files created by the shell                   (kB, -f) unlimited
Maximum size that may be locked into memory                  (kB, -l) 8192
Maximum resident set size                                    (kB, -m) unlimited
Maximum number of open file descriptors                          (-n) 1024
Maximum stack size                                           (kB, -s) 8192
Maximum amount of cpu time in seconds                   (seconds, -t) unlimited
Maximum number of processes available to a single user           (-u) 95584
Maximum amount of virtual memory available to the shell      (kB, -v) unlimited
@faho
Copy link
Member

faho commented Mar 14, 2022

This isn't something the shell should care about, to be honest. It's awkward platform-specific guff that's only in the shell because that's where it's been placed historically.

Very very few people even care about the ulimit we do have. I would be entirely okay with removing it.

So I'm rejecting this.

@faho faho closed this as completed Mar 14, 2022
@faho faho added this to the will-not-implement milestone Mar 14, 2022
@septatrix
Copy link
Contributor Author

This isn't something the shell should care about, to be honest. It's awkward platform-specific guff that's only in the shell because that's where it's been placed historically.

For fetching the limits I agree and would be fine with simply returning the content of /proc/self/limits. However the reason why it is a shell builtin is because it has to be. If one wants to set limits for new processes it cannot be done by a separate executable because it cannot set limits on a parent process.

@zanchey
Copy link
Member

zanchey commented Mar 15, 2022

Actually, on Linux, it doesn't have to - prlimit(1) alters other processes using prlimit(3) (this is a Linux-specific system call).

I think it's reasonable to add these to the existing builtin - it's a tiny patch.

@zanchey zanchey reopened this Mar 15, 2022
@zanchey
Copy link
Member

zanchey commented Mar 15, 2022

RLIMIT_NICE (since Linux 2.6.12, but see BUGS below)

This specifies a ceiling to which the process's nice value can be raised using setpriority(2) or nice(2). The actual ceiling for the nice value is calculated as 20 - rlim_cur. The useful range for this limit is thus from 1 (corresponding to a nice value of 19) to 40 (corresponding to a nice value of -20). This unusual choice of range was necessary because negative numbers cannot be specified as resource limit values, since they typically have special meanings. For example, RLIM_INFINITY typically is the same as -1. For more detail on the nice value, see sched(7).

🤯

@septatrix
Copy link
Contributor Author

Actually, on Linux, it doesn't have to - prlimit(1) alters other processes using prlimit(3) (this is a Linux-specific system call).

Huh neat. I did not know that call hat a corresponding executable.

I think it's reasonable to add these to the existing builtin - it's a tiny patch.

Yes. Simply using prlimit would also be cumbersome if one wants to set limits for a whole shell session/script without using prlimit to spawn a subshell

zanchey added a commit to zanchey/fish-shell that referenced this issue Mar 21, 2022
@zanchey zanchey linked a pull request Mar 21, 2022 that will close this issue
3 tasks
zanchey added a commit to zanchey/fish-shell that referenced this issue Mar 22, 2022
zanchey added a commit to zanchey/fish-shell that referenced this issue Mar 23, 2022
Short options are taken from prlimit(1) where appropriate.

Closes fish-shell#8786.
zanchey added a commit to zanchey/fish-shell that referenced this issue Mar 23, 2022
Short options are taken from prlimit(1) where appropriate.

Closes fish-shell#8786.
@zanchey zanchey self-assigned this Mar 24, 2022
@zanchey zanchey modified the milestones: fish-future, fish 3.5.0 Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants