Source file process_common.ml
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
open Base
let show_signal code =
if code = Sys.sigabrt then "SIGABRT"
else if code = Sys.sigalrm then "SIGALRM"
else if code = Sys.sigfpe then "SIGFPE"
else if code = Sys.sighup then "SIGHUP"
else if code = Sys.sigill then "SIGILL"
else if code = Sys.sigint then "SIGINT"
else if code = Sys.sigkill then "SIGKILL"
else if code = Sys.sigpipe then "SIGPIPE"
else if code = Sys.sigquit then "SIGQUIT"
else if code = Sys.sigsegv then "SIGSEGV"
else if code = Sys.sigterm then "SIGTERM"
else if code = Sys.sigusr1 then "SIGUSR1"
else if code = Sys.sigusr2 then "SIGUSR2"
else if code = Sys.sigchld then "SIGCHLD"
else if code = Sys.sigcont then "SIGCONT"
else if code = Sys.sigstop then "SIGSTOP"
else if code = Sys.sigtstp then "SIGTSTP"
else if code = Sys.sigttin then "SIGTTIN"
else if code = Sys.sigttou then "SIGTTOU"
else if code = Sys.sigvtalrm then "SIGVTALRM"
else if code = Sys.sigprof then "SIGPROF"
else if code = Sys.sigbus then "SIGBUS"
else if code = Sys.sigpoll then "SIGPOLL"
else if code = Sys.sigsys then "SIGSYS"
else if code = Sys.sigtrap then "SIGTRAP"
else if code = Sys.sigurg then "SIGURG"
else if code = Sys.sigxcpu then "SIGXCPU"
else if code = Sys.sigxfsz then "SIGXFSZ"
else string_of_int code
let parse_current_environment : unit -> string String_map.t =
fun () ->
let parse_env_kv key_value : (string * string) option =
String.index_opt key_value '='
|> Option.map (fun i ->
( Re.Str.string_before key_value i,
Re.Str.string_after key_value (i + 1) ))
in
Unix.environment () |> Array.to_seq
|> Seq.filter_map parse_env_kv
|> String_map.of_seq