[PATCH] D13128: Fix backend crash on multiple close of stdout.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 06:44:41 PDT 2015

ABataev added a comment.

In http://reviews.llvm.org/D13128#252630, @yaron.keren wrote:

> When stdout goes elsewhere the console, the shell creates the the output file (pipe) and will close it when clang terminates so  so why clang should close it at  all ? it did not open it.
> Practically, we have been running locally
>       Error(false), UseAtomicWrites(false) {
>   if (FD < 0 ) {
>     ShouldClose = false;
>     return;
>   }
>   if (FD <= STDERR_FILENO)
>     ShouldClose = false;
> and passing regression tests on Windows 7 and Linux, maybe this is required on other usage scenarios or OS.

I thought about it. The problem is that few lines above there is a comment (in getFD()):

  // Handle "-" as stdout. Note that when we do this, we consider ourself
  // the owner of stdout. This means that we can do things like close the
  // file descriptor when we're done and set the "binary" flag globally.

and all such stream are created with ShouldClose flag explicitly set to `true`. Should we remove all this stuff?


More information about the cfe-commits mailing list