0

I'm trying to use Lwt_process.pread_lines to get the output of a few commands. In my Lwt_main.run I call it once, and start processing each line of output separately though Lwt_stream.map, which works well.

In that processing though, if I call another Lwt_process.pread_lines, it seems to be ignored :

Lwt_process.pread_line cmd
>>= Printf.printf "blah %s\n"

I don't get blah, I don't even get an exception. I've tried pread_line and pread_lines, and it looks like anything after >>= is just ignored. If I use |> though it'll get called, but of course I actually need to use the output.

I've read the doc, and looked at the sources of Lwt_process, but I don't see anything indicating that you can't call it as many times as you'd like, it seems to create a new pipe for each process, at least on the output. Of course my external processes aren't using stdin at all, it's just a call to the df command. Am I missing something ?

I should be clear : It doesn't hang, the program does complete fine. It's just never calling whatever is trying to use the result of later commands, the first one works fine.

Thanks

Ulrar
  • 895
  • 8
  • 17
  • It should indeed be possible to call `Lwt_process.pread_lines` multiple times. Can you provide a complete minimal example to reproduce this problem? The small snippet in the question is a loose sketch, I don't think it would compile. Also, it has `Lwt_process.pread_line` (no `s`). – antron Sep 04 '18 at 14:43
  • 1
    Actually just figured it out. The problem was with the way I'm using Lwt, guess they weren't all evaluated properly .. Fixed it, sorry for the noise – Ulrar Sep 04 '18 at 15:05

0 Answers0