this repo has no description

Runc terminal mode

Changed files
+58 -12
attic
src
lib
+12 -6
attic/main.ml
···
val select : ('a, 'b) Either.t t -> ('a -> 'b) t -> 'b t
end
-
module T (A : Applicative) = struct
-
let do_thing (a : _ A.t) (v : _ A.t) =
-
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
-
let v2 = A.fmap (fun i -> if Random.int i < 5 then "hello" else "world") a in
-
v1, v2
+
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
+
let v2 =
+
A.fmap (fun i -> if Random.int i < 5 then "hello" else "world") a
+
in
+
(v1, v2)
end
module Make (S : Selective) = struct
···
| Singleton v -> [ v ]
| Cons (x, xs) -> x :: to_list xs
-
let stdout _ = ""
+
let stdout _ = ""
let build steps =
Select.apply
+12 -6
src/lib/shelter/runc.ml
···
( "process",
`Assoc
[
-
("terminal", `Bool false);
+
("terminal", `Bool true);
("user", user);
("args", strings argv);
("env", strings env);
···
let to_other_sink_as_well ~other
(Eio.Resource.T (t, handler) : Eio.Flow.sink_ty Eio.Flow.sink) =
let module Sink = (val Eio.Resource.get handler Eio.Flow.Pi.Sink) in
-
let copy_buf = Buffer.create 128 in
+
let buf = Cstruct.create 4096 in
let copy () ~src =
-
Eio.Flow.copy src (Eio.Flow.buffer_sink copy_buf);
-
Eio.Flow.copy_string (Buffer.contents copy_buf) other;
-
Sink.copy t ~src:(Buffer.contents copy_buf |> Eio.Flow.string_source);
-
Buffer.clear copy_buf
+
try
+
while true do
+
match Eio.Flow.single_read src buf with
+
| i ->
+
let bufs = [ Cstruct.sub buf 0 i ] in
+
Eio.Fiber.both
+
(fun () -> Eio.Flow.write other bufs)
+
(fun () -> Sink.copy ~src:(Eio.Flow.cstruct_source bufs) t)
+
done
+
with End_of_file -> ()
in
let single_write () x =
let _ : int = Eio.Flow.single_write other x in
+34
src/lib/shelter/shelter_main.ml
···
in
`Runc (Runc.spawn ~sw log env config rootfs)
in
+
let savedTio = Unix.tcgetattr Unix.stdin in
+
let tio =
+
{
+
savedTio with
+
(* input modes *)
+
c_ignpar = true;
+
c_istrip = false;
+
c_inlcr = false;
+
c_igncr = false;
+
c_ixon = false;
+
(* c_ixany = false; *)
+
(* c_iuclc = false; *)
+
c_ixoff = false;
+
(* output modes *)
+
c_opost = false;
+
(* control modes *)
+
c_isig = false;
+
c_icanon = false;
+
c_echo = false;
+
c_echoe = false;
+
c_echok = false;
+
c_echonl = false;
+
(* c_iexten = false; *)
+
+
(* special characters *)
+
c_vmin = 1;
+
c_vtime = 0;
+
}
+
in
+
Unix.tcsetattr Unix.stdin TCSADRAIN tio;
let start, res =
Switch.run @@ fun sw ->
let log =
···
| `Runc r -> (start, Eio.Process.await r)
| `Void v -> (start, Void.to_eio_status (Eio.Promise.await v))
in
+
+
(* restore tio *)
+
Unix.tcsetattr Unix.stdin TCSADRAIN savedTio;
+
let stop = Mtime_clock.now () in
let span = Mtime.span start stop in
let time = Mtime.Span.to_uint64_ns span in