Bash shell read error: 0: Resource temporarily unavailable

后端 未结 6 2056
感情败类
感情败类 2021-02-07 23:54

When writing a bash script. Sometimes you are running a command which opens up another program such as npm, composer.. etc. But at the same time you need to use read

6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-08 00:39

    Clearly (resource temporarily unavailable is EAGAIN) this is caused by programs that exits but leaves STDIN in nonblocking mode. Here is another solution (easiest to script?):

    perl -MFcntl -e 'fcntl STDIN, F_SETFL, fcntl(STDIN, F_GETFL, 0) & ~O_NONBLOCK'
    

提交回复
热议问题