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
//! Unix-specific OS operations, isolated behind named wrappers.
//!
//! `RSConstruct` is unix-only (Linux and macOS — the platforms the release
//! matrix builds). This module exists to keep `std::os::unix` imports and
//! `libc` calls out of the rest of the codebase, not to abstract over a
//! second platform: there are no `#[cfg(not(unix))]` branches here, because
//! there is no non-unix build to serve.
//!
//! The wrappers stay even though they no longer switch on anything — they
//! give the OS-level operations names the call sites can read, and they
//! remain the one place to look if a port is ever attempted.
/// Reset SIGPIPE to default behavior so piping to head/less doesn't cause errors.
/// Get the Unix permission mode bits for a file.
/// Whether package-manager invocations should be prefixed with `sudo`.
///
/// Returns false when:
/// - Already running as root (uid 0). sudo is a no-op and may not exist
/// (e.g. inside a bare ubuntu container).
/// - sudo is not on PATH. We can't use it; let the package manager fail
/// on its own with its native "are you root?" message.
///
/// Returns true otherwise (the normal local-dev case: non-root user with
/// passwordless or interactive sudo configured).
/// Whether the current process runs as root (effective uid 0).
/// Whether the current user may write to `path` (access(2) with `W_OK`).
/// A path that doesn't exist is "not writable" — callers that care about
/// creatability must check an existing ancestor themselves.
/// Set an environment variable for this process and everything it spawns.
///
/// `std::env::set_var` is unsafe in edition 2024 because mutating the
/// environment while another thread reads it is a data race. The one caller
/// is the PATH augmentation at the top of `main()`, before any thread —
/// tokio's included — exists. Do not call this after startup.
/// Create a symbolic link to a file.
/// Set file permissions from a Unix mode.
/// Register a SIGINT stream. Must be called inside a tokio runtime.
///
/// Registration happens at call time — unlike `tokio::signal::ctrl_c()`,
/// which registers only when its future is first polled — so the caller can
/// signal "handler installed" deterministically and close the startup window
/// where a Ctrl+C would hit the default disposition and kill the process
/// with no cleanup.