Skip to content

[bug] read -t timeout ignored when stdin is a pipe (waits for data; EOF gives rc=1 not 142) #1206

Closed

Description

@caomengxuan666
(sleep 2; echo late) | { read -t 1 x; echo "rc=$? x=[$x]"; }

GNU bash 5.3.20: rc=142 x=[] (times out after 1s; 128+14).
niu: rc=0 x=[late] (waits ~2s and consumes the delayed line — timeout ignored).

Second case, producer sends nothing:

(sleep 3) | { read -t 1 x; echo "rc=$? x=[$x]"; }

GNU: rc=142 x=[]; niu: rc=1 x=[] (returns only when the pipe closes, then reports plain EOF).

Related to #1141 (TMOUT ignored) but distinct: this is the explicit -t flag, and it also breaks the documented 142 (>128) timeout status, collapsing it into 0/1. TMOUT+-t combined (TMOUT=5; read -t 1 on a slow pipe) diverges the same way, fully explained by this bug plus #1141 — no separate precedence issue found.

Env: niubash 1.4.4 / rubash engine (git 1b14a3d), GNU bash 5.3.20 aarch64-linux-android (Termux) as oracle. Dup-check: searched issues for read -t timeout pipe — no match besides #1141.

Activity

  1. added
    bug
    gnu-baseline
    P2-medium
    area:read
    on Oct 23, 2026
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

    P2-mediumarea:readbuggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions