Search code examples
bashinputsshbackgroundbash4

read error: 0: Resource temporarily unavailable


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.


Solution

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

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