Skip to content

Commit 02873bd

Browse files
authored
[oxlog] add sigpipe::reset (#5358)
We have a number of CLI tools that panic when piped to things like `head` instead of quietly exiting. There's a long history about this within the Rust community (see rust-lang/rust#62569), but the long and short of it is that SIGPIPE really should be set to its default handler (`SIG_DFL`, terminate the process) for CLI tools. Because oxlog doesn't make any network requests, reset the SIGPIPE handler to `SIG_DFL`. I looked at also potentially doing this for some of our other CLI tools that wait on network services. This should be fine to do if and only if whenever we send data over a socket, the `MSG_NOSIGNAL` flag is set. (This causes an `EPIPE` error to be returned, but no `SIGPIPE` signal to be generated.) Rust does set this flag [here]. **However, as of Rust 1.77 this flag is not set on illumos.** That's a bug and I'll fix it in Rust upstream. [here]: https://github.com/rust-lang/rust/blob/877d36b1928b5a4f7d193517b48290ecbe404d71/library/std/src/sys_common/net.rs#L32
1 parent cf22afc commit 02873bd

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Diff for: Cargo.lock

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

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ sha3 = "0.10.8"
378378
shell-words = "1.1.0"
379379
signal-hook = "0.3"
380380
signal-hook-tokio = { version = "0.3", features = [ "futures-v0_3" ] }
381+
sigpipe = "0.1.3"
381382
similar-asserts = "1.5.0"
382383
sled = "0.34"
383384
sled-agent-client = { path = "clients/sled-agent-client" }

Diff for: dev-tools/oxlog/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ anyhow.workspace = true
99
camino.workspace = true
1010
chrono.workspace = true
1111
clap.workspace = true
12+
sigpipe.workspace = true
1213
uuid.workspace = true
1314
omicron-workspace-hack.workspace = true
1415

Diff for: dev-tools/oxlog/src/bin/oxlog.rs

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct FilterArgs {
5757
}
5858

5959
fn main() -> Result<(), anyhow::Error> {
60+
sigpipe::reset();
61+
6062
let cli = Cli::parse();
6163

6264
match cli.command {

0 commit comments

Comments
 (0)