Skip to content

Improve signal 13 (SIGPIPE) handling in basic-cli #476

Description

@Zelenya

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 $?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions