Read error: 0: The resource is temporarily unavailable

I have a bash script that asks for user input multiple times and processes the input in the background while waiting for the next input. I keep getting this error once in a while.

read error: 0: Resource temporarily unavailable

      

I suspected background processes in my script would be causing this, so I tried to put <dev / null at the end of commands that run in the background, but this bit helps a lot.

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

      

Any help would be much appreciated.

+2


source to share


2 answers


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



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

      

0


source


It's hard to diagnose without knowing more about what your program is doing, but ...



For some reason, some part of my brain tells me that it comes from the nucleus and is due to branching, but I cannot explain the reason why I think so. Try to run your script and watch your memory usage (CPU too, but it looks like memory to me). For more detailed statistics, run [than top] watch -d cat /proc/meminfo

and see what happens when you start getting this error.

0


source







All Articles