Read fails after tcpreplay with error: 0: Resource temporarily unavailabl

前端 未结 3 1387
刺人心
刺人心 2021-01-13 18:47

I have a very simple script to run. It calls tcpreplay and then ask the user to type in something. Then the read will fail with read: read error: 0: Resource temporarily una

3条回答
  •  花落未央
    2021-01-13 19:13

    Resource temporarily unavailable is EAGAIN (or EWOULDBLOCK) which is the error code for nonblocking file descriptor when no further data is available (would block if wasn't in nonblocking mode). The previous command (tcpreplay in this case) erroneously left STDIN in nonblocking mode. The shell will not correct it, and the following process isn't meant to work with non- default nonblocking STDIN.

    In your script, you can also turn off nonblocking with:

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

提交回复
热议问题