How do I create a pipe between two processes in Guile?

蓝咒 提交于 2021-02-18 18:52:02

问题


I want to create two process in Guile and send the output (stdout) from one of them as input (stdin) to the other.

Using the following example, how can this be done?

echo "foo bar" | wc

Output:

1       2       8

回答1:


Yes, you can do this using open-output-pipe:

(let ((p (open-output-pipe "wc")))
  (display "The quick brown fox jumps over the lazy dog.\n" p)
  (close-pipe p))

This is equivalent to echo "The quick brown fox jumps over the the lazy dog." | wc (including echo's implicit newline because I'm that particular, lol).

There is, of course, an open-input-pipe analogue. Read the Pipes section of the Guile manual for more details.



来源:https://stackoverflow.com/questions/18436981/how-do-i-create-a-pipe-between-two-processes-in-guile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!