coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stdbuf in pipes


From: Paul Wagner
Subject: stdbuf in pipes
Date: Fri, 17 Aug 2018 08:32:19 +0200
User-agent: Posteo Webmail

Hello!

When I use a pipe and the receiving end dies, I understand that the sending end is terminated. But when I use stdbuf on the sender, a dying receiving does not terminate the pipe. Example:

$ { i=0; while true; do echo "send $i" >&2; echo $((i++)); sleep 1; done; } | { while read s; [[ $s != 5 ]]; do echo "receive $s"; done; }
send 0
receive 0
send 1
receive 1
send 2
receive 2
send 3
receive 3
send 4
receive 4
send 5
send 6
$ { i=0; while true; do echo "send $i" >&2; stdbuf -oL echo $((i++)); sleep 1; done; } | { while read s; [[ $s != 5 ]]; do echo "receive $s"; done; }
send 0
receive 0
send 1
receive 1
send 2
receive 2
send 3
receive 3
send 4
receive 4
send 5
send 6
send 7
send 8
... [manually killed by CTRL-C]

Could anyone explain the reason for this behaviour to me?

Kindest regards,

Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]