blob: 88a1b7cc774a138c4ed95330083437c78d9f531a (
plain)
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
|
Environment variables could be injected into the main "service":
CommandMain "my_app"
inject Environment env
entry main
code
String h = env.get "HOME"
end
It would be nice to get all 3 of:
1. Efficient initialization
2. Efficient access
3. Thread-safety
Only 3 is a strict requirement.
Solutions:
* Copy the whole environment block at startup.
* At the first non-SLUL call, copy all env strings, and update
the environment block.
- But how to detect "non-SLUL calls"?
- Maybe there could be some function qualifier?
But it could be really hard to track.
* Redirect the "C-accessible" environment block to a separate page,
which is handled by userfaultfd(?) and filled in as needed.
* Map separate copy-on-write pages of the environment block at startup,
such that the SLUL "Environment" object does not see the changes
(the "copy" could even be mapped without write permission).
On glibc/Linux there's ptrctl() PR_SET_MM_ENV_START/END.
Related:
Environment block access would probably require an initialized C
library anyway. So SLUL has to somehow be able to tell when the
C library needs to be initialized (or always initialize it).
Initializing lazilly in a multi-threaded program could be tricky.
|