-
Notifications
You must be signed in to change notification settings - Fork 184
Description
I am interested into using asynchronous processes to replace some shell routines by OCaml routines. I therefore need to combine Lwt filters, but doing so results in a filter not terminating upon reading EOF on stdin.
Let us take a look at a simplified first example, where a filter is created by combining two threads running cat:
let filter_cat =
Lwt_process.pmap_lines ("cat", [| "cat" |])
let filter_cat =
Lwt_process.pmap_lines ("cat", [| "cat" |])
let filter_t () =
Lwt_io.stdin
|> Lwt_io.read_lines
|> filter_cat
|> filter_cat
|> Lwt_io.write_lines Lwt_io.stdout
let () =
Lwt_main.run (filter_t ())This filter somehow works but hangs up when its standard input closes instead
of exiting. If I remove one of the filter_cat filters, it works as expected.
I am guessing that I do not compose these filters appropriately and therefore
cannot join the two threads I am starting. What is the correct way to compose
these filters, so that the program terminates after it reads EOF on stdin?
I reported that problem on the mailing list and on SO without much luck.
System information
% uname -a
Darwin oscar.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47
PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
% ocaml -version
The OCaml toplevel, version 4.02.1
% opam show lwt
package: lwt
version: 2.4.8
repository: default
upstream-url: https://github.com/ocsigen/lwt/archive/2.4.8.tar.gz
upstream-kind: http
upstream-checksum: 2f11601bd9535b2e550026f41d9cc883
depends: ocamlfind >= 1.5.0 & (base-no-ppx | ppx_tools)
depopts: base-threads | base-unix | conf-libev | camlp4 | ssl |
react | lablgtk
installed-version: 2.4.8 [system]
available-versions: 2.3.2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6,
2.4.7, 2.4.8
description: A cooperative threads library for OCaml
This library is part of the Ocsigen project. See: