Subject: bug#44320: [PATH] [27.1] Make sure send-string-to-terminal send all contents

From: Eli Zaretskii <[email-masked]>
Date: Mon, 02 Nov 2020 17:31:56 +0200

> Date: Mon, 2 Nov 2020 11:11:22 +0800
> From: LinSun <[email-masked]>
> Cc: "[email-masked]" <[email-masked]>
> 
> Attach the log file ` testing-strace-2.log.gz` with a line more which may be a import hints.
> 
> write(6, "…", 256) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)

Thanks.

I don't think I know how to interpret this trace, or understand the
significance of ERESTARTSYS.  Was this trace collected with or without
your change in send-string-to-terminal? did fwrite succeed to write
the entire string or did it write only part of it, and if the latter,
which part was successfully written?

All I see in the trace is a series of calls to 'write' syscall,
progressively writing a large string in chunks of 4K bytes, which
seems normal.  'fwrite' is documented to return an error indication if
it doesn't succeed to write the entire buffer, but you didn't show the
return value of 'fwrite' nor what 'fflush' after it returned, so it is
hard to know what exactly happened.

I think we must understand what happens here and why, because we call
'fwrite' in 2 dozen other places, and it makes little sense to fix
only one of them.  The function where you propose the change calls
'fwrite' twice, but you suggested to fix only one of these two calls,
which also sounds strange to me.  Moreover, I don't think I see any
documentation saying that 'fwrite' can, let alone should be expected
to, fail to write the entire buffer without returning some error
indication.  On what OS do you see the problem?