aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/System/Process.h15
-rw-r--r--lib/System/Unix/Process.cpp24
-rw-r--r--lib/System/Unix/Process.inc24
3 files changed, 63 insertions, 0 deletions
diff --git a/include/llvm/System/Process.h b/include/llvm/System/Process.h
index 7733cf5..5070bbe 100644
--- a/include/llvm/System/Process.h
+++ b/include/llvm/System/Process.h
@@ -69,6 +69,21 @@ namespace sys {
/// @brief Prevent core file generation.
static void PreventCoreFiles();
+ /// This function determines if the standard input is connected directly
+ /// to a user's input (keyboard probably), rather than coming from a file
+ /// or pipe.
+ static bool StandardInIsUserInput();
+
+ /// This function determines if the standard output is connected to a
+ /// "tty" or "console" window. That is, the output would be displayed to
+ /// the user rather than being put on a pipe or stored in a file.
+ static bool StandardOutIsDisplayed();
+
+ /// This function determines if the standard error is connected to a
+ /// "tty" or "console" window. That is, the output would be displayed to
+ /// the user rather than being put on a pipe or stored in a file.
+ static bool StandardErrIsDisplayed();
+
/// @}
};
}
diff --git a/lib/System/Unix/Process.cpp b/lib/System/Unix/Process.cpp
index c1448de..cccd3ff 100644
--- a/lib/System/Unix/Process.cpp
+++ b/lib/System/Unix/Process.cpp
@@ -122,5 +122,29 @@ void Process::PreventCoreFiles() {
#endif
}
+bool Process::StandardInIsUserInput() {
+#if HAVE_ISATTY
+ return isatty(0);
+#endif
+ // If we don't have isatty, just return false.
+ return false;
+}
+
+bool Process::StandardOutIsDisplayed() {
+#if HAVE_ISATTY
+ return isatty(1);
+#endif
+ // If we don't have isatty, just return false.
+ return false;
+}
+
+bool Process::StandardErrIsDisplayed() {
+#if HAVE_ISATTY
+ return isatty(2);
+#endif
+ // If we don't have isatty, just return false.
+ return false;
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
diff --git a/lib/System/Unix/Process.inc b/lib/System/Unix/Process.inc
index c1448de..cccd3ff 100644
--- a/lib/System/Unix/Process.inc
+++ b/lib/System/Unix/Process.inc
@@ -122,5 +122,29 @@ void Process::PreventCoreFiles() {
#endif
}
+bool Process::StandardInIsUserInput() {
+#if HAVE_ISATTY
+ return isatty(0);
+#endif
+ // If we don't have isatty, just return false.
+ return false;
+}
+
+bool Process::StandardOutIsDisplayed() {
+#if HAVE_ISATTY
+ return isatty(1);
+#endif
+ // If we don't have isatty, just return false.
+ return false;
+}
+
+bool Process::StandardErrIsDisplayed() {
+#if HAVE_ISATTY
+ return isatty(2);
+#endif
+ // If we don't have isatty, just return false.
+ return false;
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab