summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml1
-rw-r--r--crates/typst-cli/Cargo.toml1
-rw-r--r--crates/typst-cli/src/main.rs4
4 files changed, 16 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 330dcce5..0afce462 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2246,6 +2246,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
+name = "sigpipe"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5584bfb3e0d348139d8210285e39f6d2f8a1902ac06de343e06357d1d763d8e6"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2705,6 +2714,7 @@ dependencies = [
"serde_json",
"serde_yaml 0.9.34+deprecated",
"shell-escape",
+ "sigpipe",
"tar",
"tempfile",
"toml",
diff --git a/Cargo.toml b/Cargo.toml
index 1f6eb5ac..66885bcf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -104,6 +104,7 @@ serde = { version = "1.0.184", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
shell-escape = "0.1.5"
+sigpipe = "0.1"
siphasher = "1"
smallvec = { version = "1.11.1", features = ["union", "const_generics", "const_new"] }
stacker = "0.1.15"
diff --git a/crates/typst-cli/Cargo.toml b/crates/typst-cli/Cargo.toml
index 8f1407d6..4b4abc55 100644
--- a/crates/typst-cli/Cargo.toml
+++ b/crates/typst-cli/Cargo.toml
@@ -46,6 +46,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
shell-escape = { workspace = true }
+sigpipe = { workspace = true }
tar = { workspace = true }
tempfile = { workspace = true }
toml = { workspace = true }
diff --git a/crates/typst-cli/src/main.rs b/crates/typst-cli/src/main.rs
index 631befe5..e4861d6f 100644
--- a/crates/typst-cli/src/main.rs
+++ b/crates/typst-cli/src/main.rs
@@ -44,6 +44,10 @@ static ARGS: LazyLock<CliArguments> = LazyLock::new(|| {
/// Entry point.
fn main() -> ExitCode {
+ // Handle SIGPIPE
+ // https://stackoverflow.com/questions/65755853/simple-word-count-rust-program-outputs-valid-stdout-but-panicks-when-piped-to-he/65760807
+ sigpipe::reset();
+
let res = dispatch();
if let Err(msg) = res {