-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When used in a pipeline hex
will crash if a downstream program exits before hex
finishes printing.
To Reproduce
$ dd if=/dev/random bs=512 count=10 | RUST_BACKTRACE=1 hx | head -n 10
10+0 records in
10+0 records out
5120 bytes (5.1 kB, 5.0 KiB) copied, 0.001144 s, 4.5 MB/s
0x000000: 0x24 0xfc 0xad 0xc8 0x27 0x0f 0x30 0x33 0x45 0x33 $...'.03E3
0x00000a: 0x4c 0x49 0xcc 0x33 0x47 0x9e 0x6d 0x38 0xc6 0x6f LI.3G.m8.o
0x000014: 0x86 0x7d 0xc2 0xd3 0x03 0x31 0xf9 0xbf 0xec 0xa4 .}...1....
0x00001e: 0x36 0x33 0xf1 0x6e 0x8b 0x43 0xe6 0xab 0x7c 0xef 63.n.C..|.
0x000028: 0x52 0xb4 0xdb 0xa1 0x63 0xe8 0x96 0x61 0xd8 0x2b R...c..a.+
0x000032: 0x47 0xc6 0xad 0x86 0x86 0xf6 0x52 0xe3 0x54 0x58 G.....R.TX
0x00003c: 0xfb 0x1b 0x80 0x50 0x79 0x80 0x11 0x31 0xa6 0x72 ...Py..1.r
0x000046: 0x50 0xf8 0x77 0x96 0x50 0x13 0x39 0x17 0xfe 0xc7 P.w.P.9...
0x000050: 0xef 0x40 0x78 0xe8 0xd5 0xfb 0xc6 0x4c 0x62 0x36 .@x....Lb6
0x00005a: 0xd9 0x32 0x18 0xe5 0x1d 0xc5 0xf0 0x95 0x35 0xdf .2......5.
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', src/libstd/io/stdio.rs:822:9
stack backtrace:
0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
1: core::fmt::write
2: std::io::Write::write_fmt
3: std::panicking::default_hook::{{closure}}
4: std::panicking::default_hook
5: std::panicking::rust_panic_with_hook
6: rust_begin_unwind
7: std::panicking::begin_panic_fmt
8: std::io::stdio::_print
9: hx::lib::run
10: hx::main
11: std::rt::lang_start::{{closure}}
12: std::rt::lang_start_internal
13: main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
In this situation head
reads 10 lines from hex
, prints them, and exits. This causes a SIGPIPE
to be sent to hex
which crashes. The expected behavior would be to handle the signal, stop printing, and cleanly exit.
Environment
Version: v0.3.0 (installed via cargo install hx
)
OS: macOS 10.14.6
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working