Skip to content

A program whose stdout reader exits early prints bend: a short write on a standard stream and exits 1 #1467

Closed

Description

@viridale

What you did

bend flood.bend -o flood && ./flood | head -1

What happened

line of output for a pipe test
bend: a short write on a standard stream

echo ${pipestatus[@]} (zsh) prints 1 0: the program exits 1 and writes an error to the terminal. bend flood.bend -o flood.js && bun flood.js | head -1 does the same.

Expected

The program stops quietly, as Unix tools do. yes | head -1 writes nothing to stderr: yes is ended by SIGPIPE (status 141). Go does this on purpose: when a write to fd 1 or 2 fails with EPIPE, the program ends by SIGPIPE. #1211 fixed the same problem in bend's own output.

Request: when a write to fd 1 or 2 fails with EPIPE, end the program silently, ideally by SIGPIPE, or at least without the message. Writes to files and sockets keep answering Fail.

This matters for any program whose output is piped into head, less, grep -q or similar.

The file

import Base

def flood(n: Nat) -> IO(Unit):
  match n:
    case 0n:
      IO.print("done")
    case 1n+p:
      IO.bind(Unit, Unit, IO.print("line of output for a pipe test"), _ => flood(p))

def main() -> IO(Unit):
  flood(200000n)

bend --version

bend 2.0.36

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 21.0.0 (clang-2100.1.1.101)

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