Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
13 lines (12 sloc) 430 Bytes
let read command =
let buffer_size = 2048 in
let buffer = Buffer.create buffer_size in
let string = String.create buffer_size in
let in_channel = Unix.open_process_in command in
let chars_read = ref 1 in
while !chars_read <> 0 do
chars_read := input in_channel string 0 buffer_size;
Buffer.add_substring buffer string 0 !chars_read
ignore (Unix.close_process_in in_channel);
Buffer.contents buffer
Something went wrong with that request. Please try again.