views:

360

answers:

2

I have a bash script which prompts for user input multiple times and processes input in the background during the time the next input is expected. I keep getting this error once in while.

read error: 0: Resource temporarily unavailable

I suspected the background processes in my script would be causing this so I tried putting a < dev/null at the end of the commands which run in the background,but that dint help much.

./somescript.sh  >> log.txt & < /dev/null

Any help would be much appreciated.

A: 

This is hard to diagnose without knowing more about what your program is doing, but...

For some reason some part of my brain is telling me that this is coming from the kernel and is related to forking, but I can't pin the reason I think that. Try running your script and watch your memory usage (processor too, but this feels like memory to me). For more detailed statistics [than top] run watch -d cat /proc/meminfo and watch what happens when you start to get that error.

Sam Bisbee
A: 

A simple redirection of error to /dev/null did the trick for me.

some_function1 2> /dev/null &
some_function2 2> /dev/null &
Sharjeel Sayed