OCaml 刷新异常行为(退出所有线程)

OCaml flush strange behaviour (exiting all threads)

我尝试使用 2 个命令实现 CLI:

当我kill watch命令时,我无法理解为什么run命令也被kill了。他们不会引发任何异常或系统信号。我注意到问题来自 flush 函数。一旦被调用,它就像一个 exit 0。怎么会?

此处来源:https://github.com/soywod/comodoro

服务器必须侦听客户端断开连接并从 conn 列表中删除连接。 这样的事情可能会奏效:

let client_thread conn =
  let in_ch = in_channel_of_descr conn in
  while true do
    try input_line in_ch |> ignore
    with End_of_file ->
     (* Remove conn from !conn and close the conn *)
  done
in

let add_conn () =
  (* ... *)
  Thread.create client_thread conn |> ignore;
  (* ... *)
in