roc-lang / roc-lang/basic-cli

Improve signal 13 (SIGPIPE) handling in basic-cli

Open
#476 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
121
Forks
45
Avg merge
18h 43m
Merged PRs (30d)
10

Description

Seems like basic-cli does not handle SIGPIPE well. I'm not sure if this is one issue or two. Is compiler diagnostic redundant because it doesn't happen on the executable? And should broken pipe error be propagated to the caller?

Example worth thousands of words:

How to reproduce it

test.roc

app [main!] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.21.0/4rAQg8kUYZ3Vksr4qMQHpaFYNiHSn9GgS7gVxghd1XYV.tar.zst",
}

import cli.Stdout

main! = |_args| write_lines!(100000)

write_lines! = |remaining| {
    if remaining == 0 {
        Ok({})
    } else {
        Stdout.line!("line")?
        write_lines!(remaining - 1)
    }
}

Run:

set -o pipefail
roc test.roc | head -n 1
echo $?

Get this result:

line
The program was killed by signal 13: Unknown signal.

This is likely a bug in the Roc compiler.
...
141

Note that executable (not roc run) works and returns 141 without any errors:

roc build test.roc
set -o pipefail
./test | head -n 1
echo $?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided test.roc and the set -o pipefail commands, then compare roc test.roc with the built executable from roc build. Trace whether the SIGPIPE diagnostic comes from basic-cli or the Roc compiler. Done means the handling and caller-visible error behavior are clarified and the unwanted diagnostic is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.