public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tim Lewis" <tim.lewis@insyde.com>
To: <devel@edk2.groups.io>
Subject: Flush on main exit?
Date: Fri, 18 Oct 2019 14:13:24 -0700	[thread overview]
Message-ID: <07be01d585f8$e27c05a0$a77410e0$@insyde.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]

I have noticed recently, when porting BSD applications, that if main exits
normally, the buffers are not flushed. This is most obvious when using
StdLib along with printf or fprintf to stdout.

 

Has anyone else noticed this? If there is a \n in the output, it gets
flushed to stdout, but if the string does not contain a \n then often
nothing happens. This is most obvious with 1-line help or logo strings that
never show up. Of course, most BSD apps use stderr for their usage, but even
this doesn't go anywhere

 

static void

usage(void)

{

 

               (void)fprintf(stderr, "usage: which [-as] program ...\n");

               exit(EXIT_FAILURE);

}

 

Per the posix standard:

 

OpenGroup says:

https://pubs.opengroup.org/onlinepubs/009695399/functions/exit.html

 

The exit() function shall then flush all open streams with unwritten
buffered data, close all open streams, and remove all files created by
<https://pubs.opengroup.org/onlinepubs/009695399/functions/tmpfile.html>
tmpfile(). Finally, control shall be terminated with the consequences
described below.

 

I have seen similar behavior with CURL and printf. 

 

Any thoughts here?

 

Tim

 


[-- Attachment #2: Type: text/html, Size: 4360 bytes --]

             reply	other threads:[~2019-10-18 21:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 21:13 Tim Lewis [this message]
2019-10-19  1:49 ` [edk2-devel] Flush on main exit? Doran, Mark

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-list 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='07be01d585f8$e27c05a0$a77410e0$@insyde.com' \
    --to=devel@edk2.groups.io \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox