[PATCH] D63859: [Support] Add getFileOrSTDIN which calls a callback if stdin is a tty

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 08:39:44 PDT 2019


abrachet added a comment.

> I stumbled on StandardInIsUserInput which might make this whole function redundant

Ah thanks James, can't believe I didn't find that before. Do you mean this function getFileOrSTDIN with the callback, or sys::fs::is_tty? For is_tty, yes, but I'm not sure for getFileOrSTDIN. I will ask on the list I originally started this discussion on if the tools calling `if (StandardInIsUserInput)` is better than doing this through getFileOrSTDIN, it might be, actually cause not all such tools will use this. Good suggestion.

Also, I found this function RedirectIO here for Windows <https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/Windows/Program.inc#L126> and Unix <https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/Unix/Program.inc#L96> they are both static and actually have different signatures, actually.  But I bring it up because the Windows version uses DuplicateHandle <https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle>. I'm guessing this test worked on Windows though or you would have said something. But I could use this if it is preferable to dup2.


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

https://reviews.llvm.org/D63859





More information about the llvm-commits mailing list