*** empty log message ***
authorroot <root>
Mon, 12 Feb 2007 17:34:58 +0000 (17:34 +0000)
committerroot <root>
Mon, 12 Feb 2007 17:34:58 +0000 (17:34 +0000)
Changes
src/iom.C
src/iom_conf.h
src/libptytty.h
src/proxy.C

diff --git a/Changes b/Changes
index 052d22d..034eb0f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -43,6 +43,8 @@ TODO: fix rounding of colors when !xft (#aaaaaa => #a9a900) (do not use correct,
           Paskevich).
         - rip out support for obsolete sgtty.h interface.
         - rip out support for non-POSIX termios variants.
+        - update libptytty.
+        - update iom.C, make it call ptytty::sanitise_stdfd on init.
 
 8.1  Thu Dec  7 22:27:25 CET 2006
         - ケリスマスプレゼント - zomg!!1, it's too early!!!
index b003fa3..1516cf2 100644 (file)
--- a/src/iom.C
+++ b/src/iom.C
@@ -151,6 +151,9 @@ static bool iom_valid;
 static struct init {
   init ()
   {
+#ifdef IOM_PREINIT
+    { IOM_PREINIT }
+#endif
     iom_valid = true;
 
 #if IOM_SIG
@@ -175,6 +178,10 @@ static struct init {
 
     tw0.start (TSTAMP_MAX);
 #endif
+
+#ifdef IOM_POSTINIT
+    { IOM_POSTINIT }
+#endif
   }
 
   ~init ()
index 91c65cc..03d7fda 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef RXVT_IOM_CONF_H__
 #define RXVT_IOM_CONF_H__
 
-#include <rxvtutil.h>
+#include "rxvtutil.h"
 
 #define IOM_IO    1
 #define IOM_TIME  1
@@ -29,5 +29,8 @@
 #define IOM_IDLE  1
 #define IOM_CHILD 1
 
+#include "libptytty.h"
+#define IOM_PREINIT ptytty::sanitise_stdfd ();
+
 #endif
 
index 34cb679..0dad6a4 100644 (file)
@@ -23,6 +23,7 @@ struct ptytty {
   bool make_controlling_tty ();
   void set_utf8_mode (bool on);
 
+  static void sanitise_stdfd ();
   static void init ();
   static ptytty *create (); // create a new pty object
 
@@ -56,6 +57,7 @@ void ptytty_close_tty (PTYTTY ptytty);
 int ptytty_make_controlling_tty (PTYTTY ptytty);
 void ptytty_set_utf8_mode (PTYTTY ptytty, int on);
 
+void ptytty_sanitise_stdfd ();
 void ptytty_init ();
 PTYTTY ptytty_create ();
 
index 4c996f0..81f3557 100644 (file)
@@ -33,6 +33,7 @@
 #include <sys/socket.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <errno.h>
 
 // helper/proxy support
 
@@ -297,8 +298,27 @@ ptytty::create ()
 }
 
 void
+ptytty::sanitise_stdfd ()
+{
+  // sanitise stdin/stdout/stderr to point to *something*.
+  for (int fd = 0; fd <= 2; ++fd)
+    if (fcntl (fd, F_GETFL) < 0 && errno == EBADF)
+      {
+        int fd2 = open ("/dev/tty", fd ? O_WRONLY : O_RDONLY);
+
+        if (fd2 < 0)
+          fd2 = open ("/dev/null", fd ? O_WRONLY : O_RDONLY);
+
+        if (fd2 != fd)
+          abort ();
+      }
+}
+
+void
 ptytty::init ()
 {
+  sanitise_stdfd ();
+
   uid_t uid = getuid ();
   gid_t gid = getgid ();