Copying a IO stream results in corruption.
- by StackedCrooked
I have a small Mongrel webserver that sends the stdout of a process to a http response:
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
This works well most of the time, but sometimes characters get duplicated. For example this is what I get from the "man ls" command:
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
For some mysterious reason capital letters get duplicated. Can anyone explain what's going on?