mailing list of musl libc
 help / color / mirror / code / Atom feed
* fgets() doesn't call fsync() before getting input
@ 2019-02-21 15:09 James Larrowe
  2019-02-21 15:22 ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: James Larrowe @ 2019-02-21 15:09 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 265 bytes --]

I'm writing a program that prints a dialogue to the screen and then asks
for input. In musl, the dialogue does not show before fgets() is called,
however in glibc it does. That causes a blank prompt and also some
confusion. Attached is a minimal example and a log.

[-- Attachment #1.2: Type: text/html, Size: 291 bytes --]

[-- Attachment #2: minimal-example.c --]
[-- Type: application/octet-stream, Size: 164 bytes --]

#include <stdio.h>

int main()
{
	char buf[9];

	fputs("Enter a seven letter word: ", stdout);
	fgets(buf, 9, stdin);
	printf("Your word is %s", buf);
	return 0;
}

[-- Attachment #3: log --]
[-- Type: application/octet-stream, Size: 310 bytes --]

chronos@localhost ~/Downloads $ gcc minimal-example.c 
chronos@localhost ~/Downloads $ ./a.out  
Enter a seven letter word: letters
Your word is letters
chronos@localhost ~/Downloads $ musl-gcc minimal-example.c 
chronos@localhost ~/Downloads $ ./a.out 
letters
Enter a seven letter word: Your word is letters

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-25 13:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 15:09 fgets() doesn't call fsync() before getting input James Larrowe
2019-02-21 15:22 ` Rich Felker
2019-02-21 16:31   ` A. Wilcox
2019-02-21 17:07     ` Rich Felker
2019-02-21 19:24       ` Laurent Bercot
2019-02-21 20:16       ` James Larrowe
2019-02-21 20:44         ` Rich Felker
2019-02-22  5:04         ` Markus Wichmann
2019-02-25 13:10           ` James Larrowe

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).