Skip to content

Commit 1e99b62

Browse files
committed
scubainit: Use nightly flag -Zon-broken-pipe=inherit to fix SIGPIPE
Rust ignores SIGPIPE by default, this patch overrides that behaviour to fix this by *not* panic'ing on Broken pipes and restore old scubainit behavior. In short, the following fails: > image: debian:latest > > aliases: > test: yes '' | echo "test" $ scuba test: > test > yes: standard output: Broken pipe * Use nightly on-broken-pipe="inherit" to inherit the behavior from the parent process, Instead of killing our process. See docs here: https://github.com/rust-lang/rust/blob/master/src/doc/unstable-book/src/compiler-flags/on-broken-pipe.md This nightly fix is definitely unstable(with very recent API changes), but hopefully they keep this interface as a compiler option the same until stabilization. * Add test to verify this doesn't break in the future * Add rust-toolchain.toml to define the locked rust version since this requires a nightly option. I specifically didn't think nightly was an issue, since you were looking into using -Zbuild-std for scubainit size minimization (which has a long path to stabilization) This has been a longstanding issue for the Rust language: - rust-lang/rust#62569 - rust-lang/rust#97889
1 parent 325fb58 commit 1e99b62

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: run_full_tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test1():
3636
f.write(in_data)
3737

3838
subprocess.check_call(["scuba", "/bin/sh", "-c", "cat file.in >> file.out"])
39+
subprocess.check_call(["scuba", "/bin/sh", "-c", "yes '' | echo 'test'"])
3940

4041
with open("file.out", "rt") as f:
4142
out_data = f.read()

Diff for: scubainit/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TARGET=x86_64-unknown-linux-musl
2323

2424
# Enable static linking
2525
STATIC_RUSTFLAGS=-C relocation-model=static
26+
NIGHTLY_RUSTFLAGS=-Zon-broken-pipe=inherit
2627

2728
export RUSTFLAGS
2829

@@ -43,15 +44,15 @@ fmt:
4344

4445
.PHONY: scubainit-debug # always build
4546
scubainit-debug: PROFILE=debug
46-
scubainit-debug: RUSTFLAGS=$(STATIC_RUSTFLAGS)
47+
scubainit-debug: RUSTFLAGS=$(STATIC_RUSTFLAGS) $(NIGHTLY_RUSTFLAGS)
4748
scubainit-debug: setup
4849
@/bin/echo -e "\nBuilding scubainit ($(PROFILE)) with RUSTFLAGS=\"$$RUSTFLAGS\""
4950
cargo build --target $(TARGET)
5051
cp target/x86_64-unknown-linux-musl/$(PROFILE)/scubainit $@
5152

5253
.PHONY: scubainit # always build
5354
scubainit: PROFILE=release
54-
scubainit: RUSTFLAGS=$(STATIC_RUSTFLAGS)
55+
scubainit: RUSTFLAGS=$(STATIC_RUSTFLAGS) $(NIGHTLY_RUSTFLAGS)
5556
scubainit: setup
5657
@/bin/echo -e "\nBuilding scubainit ($(PROFILE)) with RUSTFLAGS=\"$$RUSTFLAGS\""
5758
cargo build --target $(TARGET) --release

0 commit comments

Comments
 (0)