You are not logged in.
I have set process limits to 1000(soft) and 2000(hard) for every user to avoid someone forkbombing my system. The problem arises when I need more than 1000 processes, which happens more often than you might think. Now, I have read the relevant section on the security page on the wiki, and it says that I need to use prlimit to raise my soft limit for a session. After reading the man page, I run
prlimit --nproc=1500, and then it returns without errors, but the soft limit has not been raised. I then tried searching around, and found that
ulimit -u 1500does the trick. So I tried it and it did work, but only within the terminal, which means nothing because the terminal is a child of my login session, so I only have 1000-<other active processes> left to use. How can I raise this limit for my login session?
Last edited by DAMO238 (2020-06-07 13:12:59)
Offline
prlimit --nproc=1500You did not specify a process to adjust the limit on so it applied to the current process. That would be the prlimit command itself not its parent process the shell or the session leader?
Last edited by loqs (2020-06-06 18:32:37)
Offline
I have just found out that prlimit requires the pid of the process to set limits on. So I get the PID of i3 and use that, but the limit is still not set, as I cannot go over it. I then listed every single process that is running under my user and tried to set some limits on them. I found that I needed to use the pid of "/usr/lib/systemd/systemd --user". I will edit the wiki page to aid people that need to raise this limit.
Offline
Ok, I thought I had solved it, but after logging in and out, I don't know which processes need their limits increased.
Offline
I have a temporary solution, set all my processes to have that limit. It works for now, but it is ugly as hell:
ps --no-headers -u damien -O user | sed '/ps --no-headers -u damien -O user/d' | awk '{ system("prlimit --pid=" $1 " --nproc=2000") }'Offline
DAMO238, please stop serial posting (posting several times in a row if no one has replied) -- instead, edit your post to include more information as necessary.
Offline
pgrep -U damien systemd # that's gonna be the systemd --user process
pgrep -U damien # all your processesNo idea whether systemd/loginctl exposes the PID of the session process somewhere.
Though I'm not sure what the point of all of this is: you're setting a limit to prevent fork bombs and then raise it because it's too restricting. Just raise the initial soft limit to 2000…?
Online
DAMO238, please stop serial posting (posting several times in a row if no one has replied) -- instead, edit your post to include more information as necessary.
Apologies for that, I will keep that in mind for the future.
pgrep -U damien systemd # that's gonna be the systemd --user process pgrep -U damien # all your processesNo idea whether systemd/loginctl exposes the PID of the session process somewhere.
Though I'm not sure what the point of all of this is: you're setting a limit to prevent fork bombs and then raise it because it's too restricting. Just raise the initial soft limit to 2000…?
pgrep looks like what I need, thank you.
Offline