9

Whenever I login to shell, I get this error

-bash: fork: Resource temporarily unavailable
-bash-3.2$

I can't seem to execute any command which uses fork().

I tried ulimit -u as it doesn't use fork and it returned 35. Somehow my max process is set to 35.

I want to increase that, but I don't know where to make that change.

6 Answers 6

12

If you would like to change the limit only for that shell, you could run:

sudo ulimit -u 1000

If you want to make a more permanent change, you need to edit either /etc/limits.conf or /etc/security/limits.conf (depending on your linux distro) and add the following lines:

username hard nproc 1000

Substitute username with the actual user name

Instead of username a groupname can also be used if you prefix it with an @. If you use * it would be the default for all users

Examples:

myuser hard nproc 1000
@mygroup hard nproc 3000
*    hard nproc 500
7
  • 1
    i tried this sudo ulimit -u 1000 and it again says fork not avaiable. do i need to execute that as root Mar 2, 2013 at 2:24
  • Ahh, sudo again requires to fork a process - dang! I guess the only other way is to modify the limits.conf by directly logging in as root.
    – Tuxdude
    Mar 2, 2013 at 2:28
  • my that file is empty , all lines are comments only Mar 2, 2013 at 2:33
  • Yes, then add a newline in that file for the user with the values you're interested.
    – Tuxdude
    Mar 2, 2013 at 2:34
  • 1
    i tried that and its not working , do i need to restart somethingto makethatwork Mar 2, 2013 at 4:46
4

This can be changed in /etc/security/limits.conf. Look for lines of the form:

username hard nproc 25
@groupname hard nproc 100

These lines limit username user to 25 processes and users in group groupname to 100 processes. You will need root permissions on the machine though.

1
  • my that file is empty , is there any other system who can limit the process Mar 2, 2013 at 2:32
1

As others already mentioned look at limits.conf. When you login into Gnome, KDE or any other GUI, you have likely more than 35 processes running already.

Logout from the GUI and switch to a VT with Ctl Alt F1, for example, and login without a GUI.

Now you should be able to look into /etc/security/limits.conf. If it is empty or all commented out, you can look, if there's something in the directory /etc/security/limits.d, which has reduced the ulimit.

On the console, you should also be able to start additional processes for editing or adjusting limits.conf or files in limits.d.

0

Here some ideas :

If your limits.conf is empty, grep -l ulimit /etc/* $HOME/.* 2> /dev/null to check if someone has set a ulimit somewhere, and remove it.

After editing limits.conf, all you have to do is to logout and login again to take effect.

To gain a process, use exec. Try for instance exec sudo su to become root.

3
  • 1
    It should be enough to (re)set the ulimit, no need to change configuration (let alone system-wide configuration under /etc). And 35 processes should be plenty, something is wrong with the login process of OP.
    – vonbrand
    Mar 2, 2013 at 11:21
  • @vonbrand - absolutely. You should post this as the answer with possible things to check. +1 Mar 2, 2013 at 11:36
  • i had two files , /etc/profile and /etc/bashrc this was the line ` ulimit -n 100 -u 35 -m 200000 -d 200000 -s 8192 -c 200000 -v unlimited 2>/dev/null`
    – Mirage
    Mar 2, 2013 at 11:43
0

It should be enough to (re)set the ulimit, no need to change configuration (let alone system-wide configuration under /etc). And 35 processes should be plenty, something is wrong with the login process of OP.

In a terminal run ps -au, that should show all processes running as you, check the list (or post it here) to see if something strange is going on.

4
  • When I look at my process list, I have over 40 processes, started by the gnome environment alone. Not counting the processes I started, like firefox, emacs, bash, ... So, a ulimit of 35 isn't really that much nowadays, if you use a graphical environment. Mar 2, 2013 at 16:00
  • @OlafDietsche, Fedora 18 Gnome 3 here; I'm running Firefox, 2 xterms (one with 6 tabs) and an assortment of applets. 17 processes in all.
    – vonbrand
    Mar 2, 2013 at 16:04
  • Then Fedora is setup a lot leaner than Ubuntu (my system) by default, or you have trimmed your environment before. Mar 2, 2013 at 16:13
  • @OlafDietsche, no trimming here.
    – vonbrand
    Mar 2, 2013 at 16:20
0

There is one more possibility that the configuration for "noproc" is not working while configuring in /etc/security/limits.conf.

There is one more file which overrides your configuration /etc/security/limits.d/90-nproc.conf.

*          soft    nproc     1024
root       soft    nproc     unlimited

Here * config will override whatever you set in previous config file. So ideally you configure your setting in this file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .