如何在 Guile 的两个进程之间创建管道? [英] How do I create a pipe between two processes in Guile?

查看:50
本文介绍了如何在 Guile 的两个进程之间创建管道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Guile 中创建两个进程,并将其中一个进程的输出 (stdout) 作为输入 (stdin) 发送到另一个进程.

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

输出:

1       2       8

推荐答案

是的,您可以使用 open-output-pipe:

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

这相当于echo "The quick brown fox jumps over the lazy dog."|wc(包括 echo 的隐式换行符,因为我就是那个特别的人,哈哈).

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).

当然,有一个 open-input-pipe 类似物.阅读 Guile 手册的 Pipes 部分了解更多详情.

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

这篇关于如何在 Guile 的两个进程之间创建管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆