From: James Larrowe <larrowe.semaj11@gmail.com>
To: musl@lists.openwall.com
Subject: fgets() doesn't call fsync() before getting input
Date: Thu, 21 Feb 2019 10:09:03 -0500 [thread overview]
Message-ID: <CAEfvv4+qGgm+RuJNnurBW1yOErftNUrvDE1HuwKvUNyU6P936g@mail.gmail.com> (raw)
[-- 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
next reply other threads:[~2019-02-21 15:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 15:09 James Larrowe [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEfvv4+qGgm+RuJNnurBW1yOErftNUrvDE1HuwKvUNyU6P936g@mail.gmail.com \
--to=larrowe.semaj11@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).