1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! bash orchestrates: a script that is already running names and makes the
//! workspace, starts the server, joins at the coordinate its own choice
//! fixed, and lets go when it is done.
//!
//! Nothing here starts a process or ends one. What the client started, the
//! client cleans up, which is why the only thing this side watches is the
//! handle.
use io;
use ;
use Path;
use LocalSet;
use Session;
use Watch;
use ;
use crate;
/// What a served session produced.
///
/// Reaching one means the conversation ran and was seen out. A `Failure`
/// instead means it never got that far.
/// A rig a running bash may attach to.
///
/// | | |
/// |---|---|
/// | who chose the workspace | the client: `at` is required, exists, and is the address |
/// | what the client is handed | nothing — liveness is the workspace's to show: the join fifo is present exactly while the session serves |
/// | what ends it | the handle the initiator holds, watched and never closed here |
/// | what comes back | [`Served`] |
///
/// `at` is the workspace the client prescribed and made — left behind: a
/// reading taken later may follow source paths into it. `held` is a
/// descriptor the initiator holds open for as long as it wants the session:
/// serving ends when the last holder has let go.
///
/// A serving application is a complete standalone program: it owes nobody a
/// byte on any channel. A client that wants to know the session is up asks
/// the workspace — the join fifo is present exactly while a session serves
/// — sources the laid definitions and initiates its own channel, feeding
/// every step the same coordinate it gave the server. What the session
/// reaches is the client's decision: joining instruments that shell, its
/// functions, its subshells and what it sources; a client that wants its
/// child processes reached writes its own startup file and exports
/// `BASH_ENV` to it.
///
/// A `Failure` while serving still sees the session out: every shell
/// released or finished, the workspace's fifos gone.