You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/10/14 14:18:30 UTC

[GitHub] [incubator-nuttx-apps] juniskane edited a comment on pull request #425: Remove all fclose with stdin, stdout and stderr

juniskane edited a comment on pull request #425:
URL: https://github.com/apache/incubator-nuttx-apps/pull/425#issuecomment-708432008


   This fixes the USB console for me, but note that this is still a workaround. The following strictly conforming C program causes a crash on NuttX (tested in Flat mode build):
   ```
   #include <stdio.h>
   
   int main(void)
   {
       /* Note: order significant if want to see a crash on NuttX. */
       fclose(stdin);
       fclose(stdout);
       fclose(stderr);
       /* ... can open some file here, read/write to it, close it. ... just don't call printf() */
       return 0;
   }
   ```
   
   This kind of usage of fclose() is unlikely to appear in real programs, though.
   
   Also note that fflush(stdin) is undefined behavior in C, but we can allow it since we are the implementor.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org