# Streaming output from a program with Eio

**URL:** <https://discuss.ocaml.org/t/streaming-output-from-a-program-with-eio/17560>\
**Category:** Learning\
**Tags:** unix\
**Created:** [December 3, 2025, 1:19pm UTC](https://discuss.ocaml.org/t/streaming-output-from-a-program-with-eio/17560 "2025-12-03T13:19:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcCoquand](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/marccoquand/32/4901_2.png) [@MarcCoquand](https://discuss.ocaml.org/u/MarcCoquand)\
**Post date:** [December 3, 2025, 1:19pm UTC](https://discuss.ocaml.org/t/streaming-output-from-a-program-with-eio/17560/1 "2025-12-03T13:19:39Z")

</div>

Hey

I’m trying to understand if this is possible.

I’d like to open a new unix process, and stream the output using Seq, but I can’t really figure out the correct incantation.

This is what I’ve tried so far

```auto
Eio_main.run @@ fun env ->
  let proc_mgr = Eio.Stdenv.process_mgr env in
  let output = Eio.Process.parse_out proc_mgr Eio.Buf_read.lines ["cat"]
    ~stdin:(Eio.Flow.string_source "One two three\nOne two three\n")
   in
  output |> Seq.iter (fun line -> Eio.traceln "%S" line);; 

```

and the error I’m getting is

```auto

Exception: Failure “Unexpected data after parsing (at offset 0)”.
Raised at Stdlib.failwith in file “stdlib.ml”, line 29, characters 17-33

```

---

<div class="post-metadata">

**Author:** ![talex5](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/talex5/32/353_2.png) [@talex5](https://discuss.ocaml.org/u/talex5)\
**Post date:** [December 4, 2025, 11:29am UTC](https://discuss.ocaml.org/t/streaming-output-from-a-program-with-eio/17560/2 "2025-12-04T11:29:58Z")

</div>

You need to read the lines during parsing, not after the `Eio.Process.parse_out` is finished (and the process is gone).

The example with [Buf\_read.seq](https://ocaml-multicore.github.io/eio/eio/Eio/Buf_read/index.html#val-seq) might help.
