<div dir="ltr">What I wanted to address with this patch are:<div><br></div><div>1. Fix this line of xputs() <a href="https://github.com/landley/toybox/blob/master/toys/net/microcom.c#L113">https://github.com/landley/toybox/blob/master/toys/net/microcom.c#L113</a></div><div>The prompt text is not flushed immediately, so it is not shown to the user until the escape char is entered (which defeats the purpose of the prompt, that is to tell the user what the escape char is) and stdout is flushed by handle_esc.</div><div>To fix this we either make xputs() flush automatically, or we just add a single line of manual flush() after xputs() in microcom.c.</div><div>Either is fine with me.</div><div><br></div><div>2. The comment string before xputs() is misleading and I wanted to fix that.</div><div>I was misled by the comment line, and incorrectly thought xputs() was flushing. I only discovered otherwise after iterations of trial-and-error.</div><div>To fix this is to either make xputs() flush automatically, or just update the comment string to clarify that xputs() does _not_ flush.</div><div>Again either path is fine with me. I just merged the fixes of the two problems into one because they share the former solution. Plus xputsl() and xputsn() are also flushing, so I thought / believed xputs() was mistakenly made non-flushing.</div><div>Since the intention _is_ to keep xputs() non-flushing, how about we just update the comment of xputs() (2), and add the line of flush in microcom.c (1)?</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, May 19, 2024 at 8:41 AM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</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">On 5/16/24 06:46, Yi-Yo Chiang via Toybox wrote:<br>
> The comment string claims xputs() to write, flush and check error.<br>
> However the 'flush' operation is actually missing due to 3e0e8c6<br>
> changing the default buffering mode from 'line' to 'block'.<br>
<br>
That's sort of an Elliott question?<br>
<br>
Originally, xprintf() and friends all flushed (which is necessary to detect<br>
output errors and xexit() if so), but Elliott complained that was too slow, so<br>
the flushes got removed, and then we changed the default stdout buffering type,<br>
and...<br>
<br>
Alas, it was a whole multi-year thing. Elliott has volunteered to put manual<br>
flushes everywhere it's a problem. I've seriously thought about going<br>
exclusively to file descriptor output (dprintf() is in posix now) and leaving<br>
FILE * for input only.<br>
<br>
Personally, I honestly believe the _proper_ fix is to upgrade the kernel to use<br>
vdso to implement nagle's algorithm on file descriptor 1:<br>
<br>
<a href="https://landley.net/notes-2024.html#28-04-2024" rel="noreferrer" target="_blank">https://landley.net/notes-2024.html#28-04-2024</a><br>
<br>
But I'm not holding my breath.<br>
<br>
Rob<br>
<br>
P.S. I should post some subset of<br>
<a href="https://landley.net/bin/mkroot/latest/linux-patches/" rel="noreferrer" target="_blank">https://landley.net/bin/mkroot/latest/linux-patches/</a> to linux-kernel again. So<br>
they can be ignored again.<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div>