On Wed, Oct 25, 2023 at 1:35 AM tom kronmiller wrote:

> On Tue, Oct 24, 2023 at 12:02 PM Max Nikulin wrote:
>
>> On 24/10/2023 12:18, tom kronmiller wrote:
>> > so I unbuffered stdin and that seemed to make it happy.
>> It might be performance killer. Even fflush(NULL) before fork() may be
>> better.
>>
> In the real program in question, it hardly matters.  It is very heavily
> compute-bound on inputs which are small.  But flushing() the files seems a
> better idea in general than unbuffering, so I changed it.  (Still works.)
>

By the way, one last way to get in trouble: fflush(NULL) only flushes
output files, so an explicit fflush(stdin) is still needed.
"If the stream argument is NULL, fflush() flushes all open *output*
streams" per the man page on my system.

Reply via email to