Getting strange behavior from terminal and iTerm "-bash: fork: Resource temporarily unavailable"
bash, macos
Solution
`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.
Problem
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?