From: Rich Felker <email@example.com>
To: somethingfnothing <firstname.lastname@example.org>
Cc: "email@example.com " <firstname.lastname@example.org>
Subject: Re: [musl] fputs stdout lost characters on nonblock tty
Date: Tue, 7 Mar 2023 08:18:44 -0500 [thread overview]
Message-ID: <20230307131844.GN4163@brightrain.aerifal.cx> (raw)
On Tue, Mar 07, 2023 at 08:42:37PM +0800, somethingfnothing wrote:
> I use fputs to write string to stdout, sometimes it will lost some
> characters, the error is EAGAIN, my tty is nonblock.
> fputs did not handle this error, it reset the "wpos" "wbase" "wend"
> and return -1 when recive error, thus the last characters was lost,
> and I cannot know how much characters was lost
This is the expected behavior. fputs is expected to behave "as if" by
repeated fputc, and return an error if any of those fputc operations
would have returned an error. fputc in turn is specified to fail with
EAGAIN in this case:
[EAGAIN] [CX] [Option Start] The O_NONBLOCK flag is set for
the file descriptor underlying stream and the thread would be
delayed in the write operation. [Option End]
Nonblocking file descriptors are generally not useful with stdio. Is
there a reason you're setting it to nonblocking mode?
prev parent reply other threads:[~2023-03-07 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 12:42 somethingfnothing
2023-03-07 13:18 ` Rich Felker [this message]
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).