0
一个IO流导致我有一个小杂种Web服务器发送一个过程的标准输出到一个HTTP响应:复制腐败
response.start(200) do |head,out|
head["Content-Type"] = "text/html"
status = POpen4::popen4(command) do |stdout, stderr, stdin, pid|
stdin.close()
FileUtils.copy_stream(stdout, out)
FileUtils.copy_stream(stderr, out)
puts "Sent response."
end
end
这工作的大部分时间很好,但有时字符得到复制。例如,这是我从“man ls”命令中得到的结果:
LS(1) User Commands LS(1)
NNAAMMEE
ls - list directory contents
SSYYNNOOPPSSIISS
llss [_O_P_T_I_O_N]... [_F_I_L_E]...
DDEESSCCRRIIPPTTIIOONN
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of --ccffttuuvvSSUUXX nor ----ssoorrtt.
Mandatory arguments to long options are mandatory for short options
由于某些神秘原因大写字母被重复。任何人都可以解释发生了什么?