Skip to content

Handle stdout being closed prematurely #32

@baodrate

Description

@baodrate

When the stdout stream is closed while huniq is still printing, the program errors out:

$ seq 100000 | huniq | head
1
2
3
4
5
6
7
8
9
10
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1008:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This was mentioned before in #26, but I felt like it was worth bringing up again.

It's not a big deal other than being a bit ugly, but since this kind of workflow is common for tools like huniq, it would be nice if this wasn't presented as. see also: Misterio77/flavours#16

The error is already being propagated, so it should be simple to just silently handle std::io::ErrorKind::BrokenPipe explicitly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions