开发者

ruby creating processes and reading output

I want to create multiple processes (each with cmd + arguments).

I need the pid of the created process so I can kill it if needed.

I also want to be able to read its output (line-by-line) in a non-blocking way (otherwise I have to create th开发者_如何学Creads which I would like to avoid). Feeding its standard input is a bonus.

What's the best way to do this in ruby?


Use IO.popen to fork the process (it will return a IO object with a pid method corresponding to the forked process). You can select on the IO object to avoid blocking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜