<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>static void<o:p></o:p></p><p class=MsoNormal>usage(void)<o:p></o:p></p><p class=MsoNormal>{<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>               (void)fprintf(stderr, "usage: which [-as] program ...\n");<o:p></o:p></p><p class=MsoNormal>               exit(EXIT_FAILURE);<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Per the posix standard:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>OpenGroup says:<o:p></o:p></p><p class=MsoNormal><a href="https://pubs.opengroup.org/onlinepubs/009695399/functions/exit.html">https://pubs.opengroup.org/onlinepubs/009695399/functions/exit.html</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana",sans-serif;color:black;background:white'>The <i>exit</i>() function shall then flush all open streams with unwritten buffered data, close all open streams, and remove all files created by </span><a href="https://pubs.opengroup.org/onlinepubs/009695399/functions/tmpfile.html"><i><span style='font-size:10.0pt;font-family:"Verdana",sans-serif;color:#6666FF;background:white'>tmpfile</span></i><span style='font-size:10.0pt;font-family:"Verdana",sans-serif;color:#6666FF;background:white'>()</span></a><span style='font-size:10.0pt;font-family:"Verdana",sans-serif;color:black;background:white'>. Finally, control shall be terminated with the consequences described below.</span><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have seen similar behavior with CURL and printf. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any thoughts here?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Tim<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>

You receive all messages sent to this group.


<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/49247">View/Reply Online (#49247)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/35145254/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>