Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14634 > unrolled thread

Re: bash sockets: printf \x0a does TCP fragmentation

Started byIlkka Virta <itvirta@iki.fi>
First post2018-09-22 13:38 +0300
Last post2018-09-22 13:38 +0300
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: bash sockets: printf \x0a does TCP fragmentation Ilkka Virta <itvirta@iki.fi> - 2018-09-22 13:38 +0300

#14634 — Re: bash sockets: printf \x0a does TCP fragmentation

FromIlkka Virta <itvirta@iki.fi>
Date2018-09-22 13:38 +0300
SubjectRe: bash sockets: printf \x0a does TCP fragmentation
Message-ID<mailman.1134.1537612691.1284.bug-bash@gnu.org>
On 22.9. 02:34, Chet Ramey wrote:
> Newline? It's probably that stdout is line-buffered and the newline causes
> a flush, which results in a write(2).

Mostly out of curiosity, what kind of buffering logic does Bash (or the 
builtin printf in particular) use? It doesn't seem to be the usual stdio 
logic where you get line-buffering if printing to a terminal and block 
buffering otherwise. I get a distinct write per line even if the stdout 
of Bash itself is redirected to say /dev/null or a pipe:

  $ strace -etrace=write bash -c 'printf "foo\nbar\n"' > /dev/null
  write(1, "foo\n", 4)                    = 4
  write(1, "bar\n", 4)                    = 4
  +++ exited with 0 +++


-- 
Ilkka Virta / itvirta@iki.fi

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web