Tcl Source Code

Artifact [641126a22b]
Login

Artifact 641126a22bf9fa7e1f21a409d1a22710bb9ba500:

Attachment "open-std-channels.patch" to ticket [772288ffff] added by rmax 2003-10-02 20:15:15.
--- unix/tclUnixInit.c
+++ unix/tclUnixInit.c
@@ -170,6 +170,18 @@
     tclPlatform = TCL_PLATFORM_UNIX;
 
     /*
+     * Make sure, that the standard FDs exist.
+     */
+    if (TclOSseek(0, (Tcl_SeekOffset) 0, SEEK_CUR) == -1 && errno == EBADF)
+	open("/dev/null", O_RDONLY);
+
+    if (TclOSseek(1, (Tcl_SeekOffset) 0, SEEK_CUR) == -1 && errno == EBADF)
+	open("/dev/null", O_WRONLY);
+
+    if (TclOSseek(2, (Tcl_SeekOffset) 0, SEEK_CUR) == -1 && errno == EBADF)
+	open("/dev/null", O_WRONLY);
+
+    /*
      * The code below causes SIGPIPE (broken pipe) errors to
      * be ignored.  This is needed so that Tcl processes don't
      * die if they create child processes (e.g. using "exec" or