let monitor desc size = let buffer = String.create buffer_size in let rec read_more last_pos = let rec read_all pos = match read desc buffer 0 buffer_size with 0 when pos > last_pos -> pos | 0 -> let pos = lseek desc 0 SEEK_END in if pos < last_pos then prerr_endline "Truncated"; pos | len -> ignore (write stdout buffer 0 len); read_all (pos + len) in let new_pos = read_all last_pos in sleep 1; read_more new_pos in read_more size;; |