# bash: fork: Resource temporarily unavailable [SOLVED]

## HeXiLeD

Recently after updating to gcc 4.1 and vanilla-sources 2.6.18-rc6 i decided to emerge -e world and -e system ( something that  i had done before with NO problems ) but only this time  i got a few problems  and bash: fork: Resource temporarily unavailable is getting me seriously upset.

I now understand that this has to do with the number of process that the user is running so i checked things around  and found some solutions for somethings.

One of my main issues was this:

https://forums.gentoo.org/viewtopic-t-164479-start-0-postdays-0-postorder-asc-highlight-bash+fork+resource.html

and eventually i was able to find why :

my quote:

 *Quote:*   

> i have found the solution here:
> 
> https://forums.gentoo.org/viewtopic-t-107518-highlight-bash+fork+resource.html
> 
> https://forums.gentoo.org/viewtopic-t-164479-highlight-bash+fork+resource.html
> ...

 

However some issues still remain as i posted in  here:

https://forums.gentoo.org/viewtopic-t-414376-highlight-.html

# cat /etc/limits

```
# /etc/limits contains user resource limits.

# See limits(5).

#

# Format:

# <username> <limits-string>

#

# default entry is '*' for username

#

# Valid flags are:

# A: max address space (KB)

# C: max core file size (KB)

# D: max data size (KB)

# F: maximum filesize (KB)

# M: max locked-in-memory address space (KB) [only for root on Linux 2.0.x]

# N: max number of open files

# R: max resident set size (KB) [no effect on Linux 2.0.x]

# S: max stack size (KB)

# T: max CPU time (MIN)

# U: max number of processes

# L: max number of logins for this user

#

# Examples:

# the default entry

#* L2 D6144 R2048 S2048 U32 N32 F16384 T5 C0

# another way of suspending a user login

#guest   L0

# this account has no limits

#sysadm  -

```

even adding my user as : <username> - to allow him to to have no limits did nothing.

# cat /etc/security/limits.conf

```
# /etc/security/limits.conf

#

#Each line describes a limit for a user in the form:

#

#<domain>        <type>  <item>  <value>

#

#Where:

#<domain> can be:

#        - an user name

#        - a group name, with @group syntax

#        - the wildcard *, for default entry

#        - the wildcard %, can be also used with %group syntax,

#                 for maxlogin limit

#

#<type> can have the two values:

#        - "soft" for enforcing the soft limits

#        - "hard" for enforcing hard limits

#

#<item> can be one of the following:

#        - core - limits the core file size (KB)

#        - data - max data size (KB)

#        - fsize - maximum filesize (KB)

#        - memlock - max locked-in-memory address space (KB)

#        - nofile - max number of open files

#        - rss - max resident set size (KB)

#        - stack - max stack size (KB)

#        - cpu - max CPU time (MIN)

#        - nproc - max number of processes

#        - as - address space limit

#        - maxlogins - max number of logins for this user

#        - priority - the priority to run user process with

#        - locks - max number of file locks the user can hold

#

#<domain>      <type>  <item>         <value>

#

#*               soft    core            0

#*               hard    rss             10000

#@student        hard    nproc           20

#@faculty        soft    nproc           20

#@faculty        hard    nproc           50

#ftp             hard    nproc           0

#x#@student        -       maxlogins       4

# End of file

 
```

adding my user here as well, as : <username> - to allow him to to have no limits ALSO  did nothing.

im lost and with no ideas...

----------

## HeXiLeD

a few more details before i  commit suicide   :Confused: 

```
 ps aux | wc -l
```

result is : 127

so i start to open  terminals until  i get bash: fork: Resource temporarily unavailable  :Evil or Very Mad: 

then :

```
$ ulimit
```

gives me : UNLIMITED  :Shocked: 

----------

## HeXiLeD

i just found out that this issue only happens if i am using X

my current X packages:

x11-base/xorg-x11  7.0-r1 & x11-base/xorg-server 1.0.2-r7

```
x11-base/xorg-x11-7.0-r1  USE="(-3dfx)" INPUT_DEVICES="-acecad -aiptek -calcomp -citron -digitaledge -dmc -dynapro -elo2300 -elographics evdev -fpit -hyperpen -jamstudio -joystick keyboard -magellan -magictouch -microtouch mouse -mutouch -palmax -penmount -spaceorb -summa -synaptics -tek4957 -ur98 -vmmouse -void -wacom" VIDEO_CARDS="apm -ark -chips -cirrus -cyrix -dummy -fbdev -fglrx -glint -i128 (-i740) -i810 (-imstt) -mach64 -mga -neomagic (-newport) (-nsc) nv nvidia -r128 -radeon -rendition -s3 -s3virge -savage -siliconmotion -sis -sisusb (-sunbw2) (-suncg14) (-suncg3) (-suncg6) (-sunffb) (-sunleo) (-suntcx) -tdfx -tga -trident -tseng v4l vesa vga -via vmware -voodoo"
```

```
x11-base/xorg-server-1.0.2-r7  USE="-debug dri -ipv6 -minimal -xprint"
```

if i login without X  i dont get bash: fork: Resource temporarily unavailable 

----------

## HeXiLeD

ok a few more details ... as i am now recompiling the xorg packages... and update the baselayout...  i checked for a few more things...

bash: fork: Resource temporarily unavailable so far seems to be a fork bomb. at least  i am starting to belive that it really is and it was done on purpose somewhere...   :Evil or Very Mad:   :Question: 

Details:   :Arrow:  http://en.wikipedia.org/wiki/Fork_bomb

having read that i checked for rootkits   :Confused: 

```
# chkrootkit 

Checking `lkm'... You have     2 process hidden for readdir command

You have     2 process hidden for ps command

chkproc: Warning: Possible LKM Trojan installed
```

Before i had 5   :Shocked:   and so i went reading somethings... such as this one:

www.derkeiler.com/Mailing-Lists/securityfocus/focus-linux/2003-02/0024.html

```
If this is true, then your 'ps' binary has been replaced with one that filters

certain processes from your viewing. 
```

 *Quote:*   

> BLOODY HELL  

 

So i re-emerged sys-process/procps. However  the best way to be sure of this is to reboot and run a live cd distro and check the HD install for rootkits from the live cd. ( this way one can be sure that my rootkit pockage is not  corrupted ).

After this i re-emerged sys-process/procps again..... and ran  the rootkit check. Now i only have 1 hidden process...

hummm... something is wicked ......... somewhere... so  i remove  the old app-forensics/chkrootkit-0.45 and install app-forensics/chkrootkit-0.46a and run it.

Now i dont have any hidden process.  :Very Happy: 

...  but im  getting paranoid so i will re-emerge again  sys-process/procps

 *Quote:*   

> ...are... they after me ?...

 

i am a desperate man at this point...   :Shocked:  i dont know what  i am doing...  :Question: 

...........xorg  packages are still recompiling in the background...

AEON Flux soundtracks are playing in the back...(not helpful for my mood)

If anyone doesnt have any ideas...  i will have to wait until the X packages are done and do some testing ...

----------

## HeXiLeD

all that work + vanilla-sources 2.6.8-rc7 ( update ) and nothing . the problem remains....   :Sad: 

----------

## HeXiLeD

a few more conclusions:

This only happens to regular users and only if they are using X. (in the console there are no issues)

root is not aftected if he using X or not.

I also updated my profile and still the problem remains.

```
ls -la /etc/make.profile

rm  /etc/make.profile

ln -sf /usr/portage/profiles/default-linux/amd64/2006.1 /etc/make.profile

emerge -uDavN world
```

----------

## HeXiLeD

after almost all my hair is gone ...  i got a few more conclusions.

This might have to do with PTY devices. 

Everytime i open konsole i get the best output msg so far  about this error.

 *Quote:*   

> Konsole is unable to open a PTY (pseudo teletype). It is likely that this is due to an incorrect configuration of the PTY devices. Konsole needs to have read/write access to the PTY devices.

 

This took me to this topic here:

https://forums.gentoo.org/viewtopic-t-422980-highlight-pty.html

and i tried a few things from that post. However i found out something very weird....

```
chmod 666 on /dev/ptmx
```

solved nothing. in fact those were the perms

so i went on reading and reading... and recompiled the kernel with some changes:

frist i had like this:

```
 Device Drivers ---> 

  [code]Character devices  ---> 

   [*]   Legacy (BSD) PTY support                                                                       

   (256) Maximum number of legacy PTY in use (NEW)[/code]

```

and then  based in another topic  removed 

```
  

    []   Legacy (BSD) PTY support         
```

after reboot i got :

 *Quote:*   

> # ls -l /dev | grep pty | wc -l
> 
> 0
> 
> 

 

i have no PTY devices !! and the result is the same as when i had PTY devices.

 *Quote:*   

> CONFIG_LEGACY_PTYS:                                                                                                                              
> 
>   │                                                                                                                                                  
> 
>   │ A pseudo terminal (PTY) is a software device consisting of two                                                                                  
> ...

 

but solved nothing....

This might have to do with UDEV. but im not sure exactly where..

----------

## HeXiLeD

at this point ... i gave up.

I read one thousand and one topics here in the forums; some related to this directly and others indirectly.

Last night  i rebuilt the kernel with new settings ( for the PTY ); re-emerged udev, reconfed udev 

( and here  i got at least some better results thanks to this guy  : https://forums.gentoo.org/viewtopic.php?t=115096 )

Removed all my /dev devices, retarted and got udev populating it properly ( and this time i get  all the PTY's i need )

I must say that at least now i have udev working better than before, or so it seems.

```
# ls -l /dev | grep pty | wc -l

256
```

```
#mount

none on /proc type proc (rw)

sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)

udev on /dev type tmpfs (rw,nosuid)

devpts on /dev/pts type devpts (rw,noexec,nosuid)

none on /dev/shm type tmpfs (rw)

usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)

binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
```

my final conclusions are simple:

1: Konsole still complains about the PTY devices.

2: root does not have this problem either in the console or using X

3: all my users have this problem but ONLY when using X

4: emerged -e system again ( 4th time ) and nothing changed )

5: recompiled the kernel, gcc, glibc, udev, and the X packages plus the fag baselayout  and nothing got fixed.

6: rc-update show only shows active scripts added to boot or default and not all of them !

7: i added my user to the TTY group but that didnt solve it either...

8: I get the fork bomb only with some applications right way and other  i can open a lot more of them.

ie: if i have 5 gui apps open and go open nanoblogger in a terminal  /usr/bin/nb: fork: Resource temporarily unavailable but if go to the console  it works with no problem. however if i open all the process that i want in the console and after try to open some in X; they fail in X.

The nanoblogger is one simple example. i said that it fails... but at the same time i am able to open 10 or more opera windows.

so why the hell i only get unavailable resources for some apps and not all ? anyway... fsck it!

9: everytime o emerge nvidia-drivers i get :

```
ERROR: Kernel configuration is invalid.";               \

echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";      \

echo "         Run 'make oldconfig && make prepare' on kernel src to fix it."; 
```

but :

```
# locate autoconf.h

/usr/src/linux-2.6.16.16/include/linux/autoconf.h

/usr/src/linux-2.6.18-rc6/include/linux/autoconf.h

/usr/src/linux-2.6.18-rc7/include/linux/autoconf.h

/usr/include/linux/autoconf.h
```

```
 # locate auto.conf

/usr/src/linux-2.6.18-rc6/include/config/auto.conf.cmd

/usr/src/linux-2.6.18-rc6/include/config/auto.conf

/usr/src/linux-2.6.18-rc7/include/config/auto.conf.cmd

/usr/src/linux-2.6.18-rc7/include/config/auto.conf
```

right now all i know is that  i know less than when i started.but  i am pretty sure that the responsable for the bright idea of changing whatever HE did in some package that got me into this knows nd its probably in hawai enjoying the sun while i am here losing hair by the second.

( you know it sucks when one can only open a few windows...)

So what packages may be responsable for this ?

kernel ? udev ? Xorg ? BASELAYOUT ??? 

I am amazed how i havent got at least one developer  saying something about this ? ( i guess i feel smart ! )  :Shocked:  

sys-fs/udev-087-r1  USE="(-selinux)" 

sys-apps/baselayout-1.12.5  USE="-bootstrap -build -static unicode" 

x11-drivers/nvidia-drivers-1.0.8774  USE="dlloader" 

sys-kernel/vanilla-sources-2.6.18_rc7  USE="-build -symlink"

x11-wm/fluxbox-0.9.15.1-r2  USE="-disableslit -disabletoolbar -gnome imlib -kde nls truetype -xinerama"

x11-base/xorg-server-1.0.2-r7  USE="-debug dri -ipv6 -minimal -xprint"

x11-base/xorg-x11-7.0-r1  USE="(-3dfx)" INPUT_DEVICES="-acecad -aiptek -calcomp -citron -digitaledge -dmc -dynapro -elo2300 -elographics evdev -fpit -hyperpen -jamstudio -joystick keyboard -magellan -magictouch -microtouch mouse -mutouch -palmax -penmount -spaceorb -summa -synaptics -tek4957 -ur98 -vmmouse -void -wacom" VIDEO_CARDS="apm -ark -chips -cirrus -cyrix -dummy -fbdev -fglrx -glint -i128 (-i740) -i810 (-imstt) -mach64 -mga -neomagic (-newport) (-nsc) nv nvidia -r128 -radeon -rendition -s3 -s3virge -savage -siliconmotion -sis -sisusb (-sunbw2) (-suncg14) (-suncg3) (-suncg6) (-sunffb) (-sunleo) (-suntcx) -tdfx -tga -trident -tseng v4l vesa vga -via vmware -voodoo"

my kernel .config / my dev directory /  my fstab /  my make.conf 

The solution for this might even  be very simple but at this point and having lost 3 days around this im just going to wait until the responsable FIX's it   :Evil or Very Mad: 

----------

## HeXiLeD

ok ...  5 fscking days later... i could not give up...

i decided to try a few more things.

I removed everything in /boot  related to the kernel  and /usr/src/linux and emerged vanilla-sources 2.6.16.19  and recompiled the kernel. 

Rebooted with a new fresh stable kernel  and nothing. 

bash: fork: Resource temporarily unavailable

However it solved me a couple other problems  like this one :

```
ERROR: Kernel configuration is invalid.";               \

echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";      \

echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";
```

and this one with qc-usb drivers.

( this driver/ebuild fails with 2.6.16.19+ kernel versions ) <--- that is a bug for the ebuild or kernel guys to fix !

so it could not be the kernel.

in the meantime .. i have been  emerging -e system and -e world  in a marathon... (going to guiness book soon); recompiling udev and gcc and so on.

All i could do was to populate my /dev now in a proper way for the current system settings.

bash: fork: Resource temporarily unavailable was still around...

Notes: this only happens  with X and for regular users...

This made me think and lose hair...

So i decided to try some stuff with X.

Frist  i unloaded fluxbox and tested it only with XSESSION and voila !!! 

XSESSION allows me to open GUI's and  this time... as many as wanted... ( the fork bomb  is gone !)

Now  i only needed to know where it is.... 

I updated fluxbox to the latest masked version but the problem remained.

Then i removed my user settings making fluxbox  create sa new profile for my user. Still no solution.

After that  i instaled openbox. ( not helpful either ) bash: fork: Resource temporarily unavailable was still around...

i went back to fluxbox but this time... i didnt use XDM as login manager

GUESS FSCKING WHAT ????

```
$startx
```

and now the fork bomb is god damn gone !!!! 

IT'S THE LOGIN MANAGER !!!! XDM !!! FSCK IT !

The problem  is in XDM . since xdm is part of Xorg... well... now the developers will have something to fix. 

i can sleep now ....   :Very Happy: 

----------

## EchoVibes

Thats a long road u had to walk mate, but in the end u managed to overcome the problem, and thats great news.

btw could u post which version of xdm ur using? cause i also use xdm and never had such problem  :Wink: 

----------

