Linux-insides: Limits on resources in Linux
1–8 of 8 posts
Re: Linux-insides: Limits on resources in Linux
#2Does it actually work? On my system ulimit is a shell builtin, not a separate command:
$ strace ulimit -s
strace: Can't stat 'ulimit': No such file or directoryRe: Linux-insides: Limits on resources in Linux
#3> $ strace ulimit -s 2>&1 | grep rl Does it actually work? On my system ulimit is a shell builtin, not a separate command: $ strace ulimit -s strace: Can't stat 'ulimit': No such file or directory
Re: Linux-insides: Limits on resources in Linux
#4Re: Linux-insides: Limits on resources in Linux
#5> $ strace ulimit -s 2>&1 | grep rl Does it actually work? On my system ulimit is a shell builtin, not a separate command: $ strace ulimit -s strace: Can't stat 'ulimit': No such file or directory
Re: Linux-insides: Limits on resources in Linux
#6> $ strace ulimit -s 2>&1 | grep rl Does it actually work? On my system ulimit is a shell builtin, not a separate command: $ strace ulimit -s strace: Can't stat 'ulimit': No such file or directory
Bash has a few builtin that are clones of commands (mostly from coreutils). To execute the command instead of the builtin, just give the full path to the command (not sure and cannot verify, right now but this might mean either /bin/ulimit or /use/bin/ulimit ). There are other notable ones like echo, and time where the builtins have slightly different behaviour than the commands.
Now, there's no solid reason why it couldn't work like `unshare` or `chroot` (which also wrap operations that modify the current process), and spawn a second child shell with the modified properties. But, that isn't how it works on any system I have ever used, isn't what users expect, and isn't in conformance with POSIX.
To quote POSIX: Since `ulimit` affects the current shell execution environment, it is always provided as a shell regular built-in.
Re: Linux-insides: Limits on resources in Linux
#7Seems odd that it doesn't mention cgroups or the CLONE_* flags used to create namespaces for containers.
Re: Linux-insides: Limits on resources in Linux
#8Earlier quoted context omitted.
Bash has a few builtin that are clones of commands (mostly from coreutils). To execute the command instead of the builtin, just give the full path to the command (not sure and cannot verify, right now but this might mean either /bin/ulimit or /use/bin/ulimit ). There are other notable ones like echo, and time where the builtins have slightly different behaviour than the commands.
While what you said is true in general; ulimit is usually not a separate program. It modifies the state of the current process (similarly to `cd`), so it has to be built-in. Now, there's no solid reason why it couldn't work like `unshare` or `chroot` (which also wrap operations that modify the current process), and spawn a second child shell with the modified properties. But, that isn't how it works on any system I h…
We have fork() and exec(), and resource limits carry across exec(), so it does not /have/ to be a built-in.