首页 > 解决方案 > 使用 uiop:launch-program 管道超过两个子进程不起作用

问题描述

我正在尝试使用 管道传输三个或更多子进程的输入/输出uiop:launch-program,相当于 shell 中的类似内容:C:\> ipconfig | sort | strings.

我尝试获取一个程序的输出流并将其设置为另一个程序的输入流,重复直到最后一个程序。下面是我的三个子进程的代码,它不起作用。

(uiop:run-program "strings"
                  :input (uiop:process-info-output
                          (uiop:launch-program "sort"
                                               :input
                                               (uiop:process-info-output
                                                (uiop:launch-program "ipconfig"
                                                                     :output :stream))
                                               :output :stream))
                  :output :interactive)

当我认为它不应该时,这会导致一个空字符串。

有趣的是,两个子流程之间的管道按预期工作。下面是我的两个子流程的代码,它有效。

(uiop:run-program "sort"
                    :input
                    (uiop:process-info-output
                     (uiop:launch-program "ipconfig"
                                          :output :stream))
                    :output :string)

这将返回一个非空字符串,这是我所期望的。

请帮助我实现将三个程序组合在一起的梦想。

标签: common-lispio-redirectionsbcluiop

解决方案


推荐阅读