<div dir="ltr">to me this is another argument why unbuffered shouldn't be the default, but "echo is at least line buffered" is the minimum i need to avoid the xargs test flake, so that's all i'm going for today :-)<div><br></div><div>it's guessable from the mention of xargs, echo, and parallelism, but it was an accident that i forgot to include the specific failure i was seeing, so for completeness:</div><div><br></div><div>FAIL: xargs max-proc=2<br>echo -ne 'y\ny\ny\n' | xargs -n 1 -P 2<br>--- expected 2021-04-24 14:46:41.511976909 +0000<br>+++ actual 2021-04-24 14:46:41.551976908 +0000<br>@@ -1,3 +1,3 @@<br>+yy<br>+<br> y<br>-y<br>-y<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 26, 2021 at 3:43 PM enh <<a href="mailto:enh@google.com">enh@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">This patch does two things:<br><br>1. Enable line buffering for echo and yes. I found this through test<br> flakiness from the toybox xargs tests running in CI on devices where<br> "echo" is provided by toybox. For `echo y`, GNU echo does one write<br> of "y\n" but toybox echo was doing two writes, which makes it more<br> likely (4% on the heavily-loaded CI machines) for writes from the two<br> processes to be interleaved.<br><br>2. Fix line buffering on glibc if you're calling `toybox foo` rather<br> than `foo`. Otherwise we come through once and switch to unbuffered<br> mode, then again and switch to line buffered mode --- which doesn't<br> seem to actually work in glibc unless you specify a buffer (so<br> passing toybuf and sizeof(toybuf) works, but NULL and 0 doesn't).<br><br>I hit the second issue trying to reproduce the first issue on the desktop<br>rather than on Android.<br><br>(If you're scratching your head wondering "why yes(1) too, not just<br>echo(1)?", that represents a blind alley I went down when I mistook<br>which tool was in use. It seemed like the same principle should apply,<br>and it matches what other implementations do.)<br>---<br> main.c | 2 +-<br> toys/other/yes.c | 2 +-<br> toys/posix/echo.c | 2 +-<br> 3 files changed, 3 insertions(+), 3 deletions(-)<br></div>
</blockquote></div>