+12
-6
attic/main.ml
+12
-6
attic/main.ml
···
13
13
val select : ('a, 'b) Either.t t -> ('a -> 'b) t -> 'b t
14
14
end
15
15
16
-
17
16
module T (A : Applicative) = struct
18
-
19
17
let do_thing (a : _ A.t) (v : _ A.t) =
20
-
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
21
-
let v2 = A.fmap (fun i -> if Random.int i < 5 then "hello" else "world") a in
22
-
v1, v2
18
+
let v1 =
19
+
A.mbind
20
+
(fun i ->
21
+
if Random.int i < 5 then A.mbind (fun v -> A.return @@ v ^ "hello") v
22
+
else A.return "world")
23
+
a
24
+
in
25
+
let v2 =
26
+
A.fmap (fun i -> if Random.int i < 5 then "hello" else "world") a
27
+
in
28
+
(v1, v2)
23
29
end
24
30
25
31
module Make (S : Selective) = struct
···
84
90
| Singleton v -> [ v ]
85
91
| Cons (x, xs) -> x :: to_list xs
86
92
87
-
let stdout _ = ""
93
+
let stdout _ = ""
88
94
89
95
let build steps =
90
96
Select.apply
+12
-6
src/lib/shelter/runc.ml
+12
-6
src/lib/shelter/runc.ml
···
151
151
( "process",
152
152
`Assoc
153
153
[
154
-
("terminal", `Bool false);
154
+
("terminal", `Bool true);
155
155
("user", user);
156
156
("args", strings argv);
157
157
("env", strings env);
···
274
274
let to_other_sink_as_well ~other
275
275
(Eio.Resource.T (t, handler) : Eio.Flow.sink_ty Eio.Flow.sink) =
276
276
let module Sink = (val Eio.Resource.get handler Eio.Flow.Pi.Sink) in
277
-
let copy_buf = Buffer.create 128 in
277
+
let buf = Cstruct.create 4096 in
278
278
let copy () ~src =
279
-
Eio.Flow.copy src (Eio.Flow.buffer_sink copy_buf);
280
-
Eio.Flow.copy_string (Buffer.contents copy_buf) other;
281
-
Sink.copy t ~src:(Buffer.contents copy_buf |> Eio.Flow.string_source);
282
-
Buffer.clear copy_buf
279
+
try
280
+
while true do
281
+
match Eio.Flow.single_read src buf with
282
+
| i ->
283
+
let bufs = [ Cstruct.sub buf 0 i ] in
284
+
Eio.Fiber.both
285
+
(fun () -> Eio.Flow.write other bufs)
286
+
(fun () -> Sink.copy ~src:(Eio.Flow.cstruct_source bufs) t)
287
+
done
288
+
with End_of_file -> ()
283
289
in
284
290
let single_write () x =
285
291
let _ : int = Eio.Flow.single_write other x in
+34
src/lib/shelter/shelter_main.ml
+34
src/lib/shelter/shelter_main.ml
···
321
321
in
322
322
`Runc (Runc.spawn ~sw log env config rootfs)
323
323
in
324
+
let savedTio = Unix.tcgetattr Unix.stdin in
325
+
let tio =
326
+
{
327
+
savedTio with
328
+
(* input modes *)
329
+
c_ignpar = true;
330
+
c_istrip = false;
331
+
c_inlcr = false;
332
+
c_igncr = false;
333
+
c_ixon = false;
334
+
(* c_ixany = false; *)
335
+
(* c_iuclc = false; *)
336
+
c_ixoff = false;
337
+
(* output modes *)
338
+
c_opost = false;
339
+
(* control modes *)
340
+
c_isig = false;
341
+
c_icanon = false;
342
+
c_echo = false;
343
+
c_echoe = false;
344
+
c_echok = false;
345
+
c_echonl = false;
346
+
(* c_iexten = false; *)
347
+
348
+
(* special characters *)
349
+
c_vmin = 1;
350
+
c_vtime = 0;
351
+
}
352
+
in
353
+
Unix.tcsetattr Unix.stdin TCSADRAIN tio;
324
354
let start, res =
325
355
Switch.run @@ fun sw ->
326
356
let log =
···
333
363
| `Runc r -> (start, Eio.Process.await r)
334
364
| `Void v -> (start, Void.to_eio_status (Eio.Promise.await v))
335
365
in
366
+
367
+
(* restore tio *)
368
+
Unix.tcsetattr Unix.stdin TCSADRAIN savedTio;
369
+
336
370
let stop = Mtime_clock.now () in
337
371
let span = Mtime.span start stop in
338
372
let time = Mtime.Span.to_uint64_ns span in