This is an archive of the discontinued LLVM Phabricator instance.

[Support] Add sys::fs::is_tty() wrapper around isatty(3)
AbandonedPublic

Authored by abrachet on Jun 26 2019, 7:36 PM.

Details

Summary

Adds a wrapper in Support/Filesystem.h for determining if a file descriptor refers to a terminal.

This patch is needed by an upcoming patch which needs to know if stdin has redirected input or not.

Diff Detail

Event Timeline

abrachet created this revision.Jun 26 2019, 7:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2019, 7:36 PM

Code change looks good, but one very weird thing I noticed is that your change in the header is in "FileSystem.h" but the definitions are in "Path.inc". This seems wrong, and should probably be fixed, possibly by adding FileSystem.inc?

Also, you should definitely get some more reviewers to look at this, as I don't want to be making the decision on that alone. Take a look at the commits history for the files you touched.

llvm/include/llvm/Support/FileSystem.h
640

What about a) if the file descriptor is invalid (doesn't refer to anything) or b) doesn't refer to a terminal (in other words, be explicit with the false as well as the true)?

abrachet abandoned this revision.Jul 4 2019, 9:17 AM

Already exists in sys::Process::StandardInIsUserInput.