···1313 val select : ('a, 'b) Either.t t -> ('a -> 'b) t -> 'b t
1414end
15151616-1716module T (A : Applicative) = struct
1818-1917 let do_thing (a : _ A.t) (v : _ A.t) =
2020- let v1 = A.mbind (fun i -> if Random.int i < 5 then A.mbind (fun v -> A.return @@ v ^ "hello") v else A.return "world") a in
2121- let v2 = A.fmap (fun i -> if Random.int i < 5 then "hello" else "world") a in
2222- v1, v2
1818+ let v1 =
1919+ A.mbind
2020+ (fun i ->
2121+ if Random.int i < 5 then A.mbind (fun v -> A.return @@ v ^ "hello") v
2222+ else A.return "world")
2323+ a
2424+ in
2525+ let v2 =
2626+ A.fmap (fun i -> if Random.int i < 5 then "hello" else "world") a
2727+ in
2828+ (v1, v2)
2329end
24302531module Make (S : Selective) = struct
···8490 | Singleton v -> [ v ]
8591 | Cons (x, xs) -> x :: to_list xs
86928787- let stdout _ = ""
9393+ let stdout _ = ""
88948995 let build steps =
9096 Select.apply
+12-6
src/lib/shelter/runc.ml
···151151 ( "process",
152152 `Assoc
153153 [
154154- ("terminal", `Bool false);
154154+ ("terminal", `Bool true);
155155 ("user", user);
156156 ("args", strings argv);
157157 ("env", strings env);
···274274let to_other_sink_as_well ~other
275275 (Eio.Resource.T (t, handler) : Eio.Flow.sink_ty Eio.Flow.sink) =
276276 let module Sink = (val Eio.Resource.get handler Eio.Flow.Pi.Sink) in
277277- let copy_buf = Buffer.create 128 in
277277+ let buf = Cstruct.create 4096 in
278278 let copy () ~src =
279279- Eio.Flow.copy src (Eio.Flow.buffer_sink copy_buf);
280280- Eio.Flow.copy_string (Buffer.contents copy_buf) other;
281281- Sink.copy t ~src:(Buffer.contents copy_buf |> Eio.Flow.string_source);
282282- Buffer.clear copy_buf
279279+ try
280280+ while true do
281281+ match Eio.Flow.single_read src buf with
282282+ | i ->
283283+ let bufs = [ Cstruct.sub buf 0 i ] in
284284+ Eio.Fiber.both
285285+ (fun () -> Eio.Flow.write other bufs)
286286+ (fun () -> Sink.copy ~src:(Eio.Flow.cstruct_source bufs) t)
287287+ done
288288+ with End_of_file -> ()
283289 in
284290 let single_write () x =
285291 let _ : int = Eio.Flow.single_write other x in
+34
src/lib/shelter/shelter_main.ml
···321321 in
322322 `Runc (Runc.spawn ~sw log env config rootfs)
323323 in
324324+ let savedTio = Unix.tcgetattr Unix.stdin in
325325+ let tio =
326326+ {
327327+ savedTio with
328328+ (* input modes *)
329329+ c_ignpar = true;
330330+ c_istrip = false;
331331+ c_inlcr = false;
332332+ c_igncr = false;
333333+ c_ixon = false;
334334+ (* c_ixany = false; *)
335335+ (* c_iuclc = false; *)
336336+ c_ixoff = false;
337337+ (* output modes *)
338338+ c_opost = false;
339339+ (* control modes *)
340340+ c_isig = false;
341341+ c_icanon = false;
342342+ c_echo = false;
343343+ c_echoe = false;
344344+ c_echok = false;
345345+ c_echonl = false;
346346+ (* c_iexten = false; *)
347347+348348+ (* special characters *)
349349+ c_vmin = 1;
350350+ c_vtime = 0;
351351+ }
352352+ in
353353+ Unix.tcsetattr Unix.stdin TCSADRAIN tio;
324354 let start, res =
325355 Switch.run @@ fun sw ->
326356 let log =
···333363 | `Runc r -> (start, Eio.Process.await r)
334364 | `Void v -> (start, Void.to_eio_status (Eio.Promise.await v))
335365 in
366366+367367+ (* restore tio *)
368368+ Unix.tcsetattr Unix.stdin TCSADRAIN savedTio;
369369+336370 let stop = Mtime_clock.now () in
337371 let span = Mtime.span start stop in
338372 let time = Mtime.Span.to_uint64_ns span in