BASH: Best architecture for reading from two input streams

后端 未结 2 1908
长情又很酷
长情又很酷 2020-12-21 00:42

Simple script here:

a) constantly read from a socket and store values in an associative array
b) constantly read values from s

2条回答
  •  情话喂你
    2020-12-21 00:52

    Bash is not the right tool for this. This problem is typically solved using the select(2) or poll(2) system calls, which allow you to wait on multiple file descriptors simultaneously without spinning. Bash does not have an interface to either of those.

    I'd recommend using a scripting language such as Python or Perl (whatever you're comfortable with, really) that provides an interface with select or poll (e.g. Python's select module).

提交回复
热议问题