[PATCH] D68164: [Commandline] Clear error on raw_ostream when there is parsing error.

Yuanfang Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 10:50:39 PDT 2019


ychen added a comment.

In D68164#1687442 <https://reviews.llvm.org/D68164#1687442>, @ruiu wrote:

> In D68164#1687414 <https://reviews.llvm.org/D68164#1687414>, @MaskRay wrote:
>
> > POSIX has stated that file descriptors 0, 1 or 2 should not be closed. The is stated in many parts, e.g.
> >
> > > Applications should not execute programs with file descriptor 0 not open for reading or with file descriptor 1 or 2 not open for writing, as this might cause the executed program to misbehave.  In order not to pass on these file descriptors to an executed program, applications should not just close them but should reopen them on, for example, /dev/null.
> >
> > The change is justified if you can give an example of a different file descriptor.
>
>
> I believe that sentence is talking about stdin/stdout/stderr and forking a new process. As long as you don't create a new process, I think you are free to close 0, 1 and 2.
>
> That said I agree with you that we shouldn't close 0, 1 and 2 on exit. I'm not sure if we are doing this at the moment, but if we do, I think we should stop doing that.


Comments in close-stderr.ll says "Test that the error handling when writing to stderr fails exits the program cleanly rather than aborting." We shouldn't close it and I believe we're not doing it although users could do it at the commandline if they wish and we should exit cleanly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68164/new/

https://reviews.llvm.org/D68164





More information about the llvm-commits mailing list