Skip to content

Commit da14299

Browse files
Handle SIGPIPE
Fix `SIGPIPE` being ignored, which would cause the `mullvad-cli` to panic if it received a `PIPE` signal (e.g. it was piped into `echo`).
1 parent 1c19bb1 commit da14299

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Line wrap the file at 100 chars. Th
3232
- Remove "Any" option for tunnel protocol. The default is now WireGuard.
3333

3434
### Fixed
35+
- Fix `mullvad-cli` panicking if it tried to write to a closed pipe on Linux and macOS.
36+
3537
#### macOS
3638
- Fix routing issue caused by upgrading `tun`.
3739

Cargo.lock

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mullvad-cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ talpid-types = { path = "../talpid-types" }
2929

3030
mullvad-management-interface = { path = "../mullvad-management-interface" }
3131
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "fs"] }
32+
sigpipe = "0.1"
3233
serde = { workspace = true }
3334
serde_json = { workspace = true }
3435

mullvad-cli/src/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ enum Cli {
152152

153153
#[tokio::main]
154154
async fn main() -> Result<()> {
155+
// Handle SIGPIPE
156+
// https://stackoverflow.com/questions/65755853/simple-word-count-rust-program-outputs-valid-stdout-but-panicks-when-piped-to-he/65760807
157+
// https://github.com/rust-lang/rust/issues/119980
158+
// https://github.com/typst/typst/pull/5444
159+
sigpipe::reset();
160+
155161
match Cli::parse() {
156162
Cli::Account(cmd) => cmd.handle().await,
157163
Cli::Bridge(cmd) => cmd.handle().await,

0 commit comments

Comments
 (0)