Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting strange behavior from terminal and iTerm "-bash: fork: Resource temporarily unavailable"

Tags:

bash

macos

When I open iTerm, I'm getting this message:

Last login: Mon Oct 22 12:20:25 on ttys002
-bash: fork: Resource temporarily unavailable
-bash-3.2$

and when I open Terminal, I'm getting:

Last login: Mon Oct 22 12:25:47 on ttys002
-bash: fork: Resource temporarily unavailable
Williams-MacBook-Pro:~ william$

and whenever I try to put in a command, like ls or cd i get this error message:

-bash: fork: Resource temporarily unavailable

So I basically can't do anything. I've tried googling the error message, but not getting anywhere. I'm on a Mac with Mountain Lion if that helps. Thanks.

EDIT:

I ran "ps"

to get the process status and i got this as a response from terminal:

Williams-MacBook-Pro:~ william$ ps
PID TTY TIME CMD
203 ttys000 0:00.08 -bash
254 ttys001 0:00.03 bash /Users/william/.rvm/scripts/wrapper ruby-1.9.3-p2
553 ttys001 0:00.03 bash /Users/william/.rvm/scripts/wrapper ruby-1.9.3-p2
785 ttys001 0:00.03 bash /Users/william/.rvm/scripts/wrapper ruby-1.9.3-p2
814 ttys001 0:00.48 -bash
1019 ttys001 0:00.03 bash /Users/william/.rvm/scripts/wrapper ruby-1.9.3-p2

and the message

bash /Users/william/.rvm/scripts/wrapper ruby-1.9.3-p2

keeps listing a few hundred times in the terminal (couldn't post it all cause it probably wouldn't fit into this box and it just keeps going the same), so I'm guessing there's something sketchy going on with that file. Does anyone know how to fix this?

like image 423
William Stocks Avatar asked Oct 22 '12 10:10

William Stocks


4 Answers

bash - and all the other shells, too - use the fork system call on Unix systems in order to actually create the process that you want to launch from the shell. In this case, bash tells you that the system call ended with Resource temporarily unavailable, which translates to the errno value of 11, which is equal to EAGAIN.

The manual page for fork says that it may set errno to EAGAIN when :

  • It cannot allocate sufficient memory to copy the parent's page tables and allocate a task structure for the child.
  • It was not possible to create a new process because the caller's RLIMIT_NPROC resource limit was encountered. To exceed this limit, the process must have either the CAP_SYS_ADMIN or the CAP_SYS_RESOURCE capability.

In this case, I think that the first reason doesn't really sound realistic, unless you are actually out of memory, so I guess you just must've hit the limit for the number of running processes for your user.

like image 184
Daniel Kamil Kozar Avatar answered Oct 21 '22 04:10

Daniel Kamil Kozar


See setting higher limits on the number of processes.

http://blog.ghostinthemachines.com/2010/01/19/mac-os-x-fork-resource-temporarily-unavailable/

like image 26
software engineer Avatar answered Oct 21 '22 04:10

software engineer


To resolve on Yosemite and newer versions of Mac OS, use https://superuser.com/a/838630. I was able to resolve by updating the plist files and rebooting - the ulimit commands were unnecessary.

like image 1
jcasner Avatar answered Oct 21 '22 04:10

jcasner


For iTerm, opening a new tab worked for me

like image 1
Warri Avatar answered Oct 21 '22 03:10

Warri