Add functions for determining if the stdin/out/err is connected to a
authorReid Spencer <rspencer@reidspencer.com>
Sat, 1 Jan 2005 22:29:26 +0000 (22:29 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sat, 1 Jan 2005 22:29:26 +0000 (22:29 +0000)
console or not.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19233 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Process.h
lib/System/Unix/Process.cpp
lib/System/Unix/Process.inc

index 7733cf5f65689377bc4d229640ac328fed2923f9..5070bbe4047d7361f06b76d281761b80a24c1d4d 100644 (file)
@@ -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();
+
     /// @}
   };
 }
index c1448de8d40f1e49b11ef3b6e7f49248ac448ce3..cccd3ffcb67bbd6f218da5aae5ec62d2ee38fbb1 100644 (file)
@@ -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
index c1448de8d40f1e49b11ef3b6e7f49248ac448ce3..cccd3ffcb67bbd6f218da5aae5ec62d2ee38fbb1 100644 (file)
@@ -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