Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Victor Sudakov
The Wanderer wrote: > On 2021-07-05 at 22:42, Victor Sudakov wrote: > > > Greg Wooledge wrote: > > >> And in any case, when you test this stuff, use the subshells. > > > > Well, my goal is to find a way to limit programs run from cron, PHP's > > proc_open() etc., not from the interactive shell

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Victor Sudakov
Victor Sudakov wrote: > > FreeBSD has a simple way to run some ad-hoc program with memory limits: > > $ limits -m 2G ./mytest > memoryuse 2097152 kB > vmemoryuse infinity kB > $ limits -m 1G ./mytest > memoryuse 1048576 kB > vmemoryuse infinity

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Victor Sudakov
Greg Wooledge wrote: > On Mon, Jul 05, 2021 at 11:01:25PM -0400, The Wanderer wrote: > > On 2021-07-05 at 22:42, Victor Sudakov wrote: > > > > > Greg Wooledge wrote: > > > > >> And in any case, when you test this stuff, use the subshells. > > > > > > Well, my goal is to find a way to limit pro

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Greg Wooledge
On Mon, Jul 05, 2021 at 11:11:06PM -0400, Greg Wooledge wrote: > > > $ prlimit --as=1048576 /bin/ls > > > /bin/ls: error while loading shared libraries: libselinux.so.1: failed to > > > map segment from shared object > > Sounds like you set it too low. Remember, setrlimit(2) and prlimit(2) > say

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Greg Wooledge
On Mon, Jul 05, 2021 at 11:01:25PM -0400, The Wanderer wrote: > On 2021-07-05 at 22:42, Victor Sudakov wrote: > > > Greg Wooledge wrote: > > >> And in any case, when you test this stuff, use the subshells. > > > > Well, my goal is to find a way to limit programs run from cron, PHP's > > proc_o

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread The Wanderer
On 2021-07-05 at 22:42, Victor Sudakov wrote: > Greg Wooledge wrote: >> And in any case, when you test this stuff, use the subshells. > > Well, my goal is to find a way to limit programs run from cron, PHP's > proc_open() etc., not from the interactive shell. What would you advise? Is there a

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Victor Sudakov
Greg Wooledge wrote: [dd] > > > > > > # ulimit -m 1048576 ; stress-ng --vm 1 --vm-bytes 8G > > stress-ng: info: [10961] defaulting to a 86400 second (1 day, 0.00 secs) > > run per stressor > > stress-ng: info: [10961] dispatching hogs: 1 vm > > > > stress-ng is not killed. Swap is not enabl

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Greg Wooledge
On Mon, Jul 05, 2021 at 10:57:03PM +0700, Victor Sudakov wrote: > Greg Wooledge wrote: > > One way would be: > > > > (ulimit -m 2097152; ./mytest) > > Is the value in KB or MB? Seems KB. Please read the documentation. unicorn:~$ ulimit -a | grep -- -m max memory size (kbytes, -m) un

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Victor Sudakov
Victor Sudakov wrote: > > This assumes you're using bash as your shell. > > I am, as you see above. I expect stress-ng to be killed when it tries to > allocate 2G of memory but it's not happening. Can you reproduce your > advice? Even as root, there is no "Operation not permitted" message, but th

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Victor Sudakov
Greg Wooledge wrote: > On Mon, Jul 05, 2021 at 10:15:19AM +0700, Victor Sudakov wrote: > > FreeBSD has a simple way to run some ad-hoc program with memory limits: > > > > $ limits -m 2G ./mytest > > memoryuse 2097152 kB > > vmemoryuse infinity kB > > $ limits -m 1G ./myte

Re: Limit memory consumption of an ad hoc process

2021-07-05 Thread Greg Wooledge
On Mon, Jul 05, 2021 at 10:15:19AM +0700, Victor Sudakov wrote: > FreeBSD has a simple way to run some ad-hoc program with memory limits: > > $ limits -m 2G ./mytest > memoryuse 2097152 kB > vmemoryuse infinity kB > $ limits -m 1G ./mytest > memoryuse 104857

Limit memory consumption of an ad hoc process

2021-07-04 Thread Victor Sudakov
Dear Colleagues, FreeBSD has a simple way to run some ad-hoc program with memory limits: $ limits -m 2G ./mytest memoryuse 2097152 kB vmemoryuse infinity kB $ limits -m 1G ./mytest memoryuse 1048576 kB vmemoryuse infinity kB How do I do the sam