summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--tests/unixInit.test15
-rw-r--r--unix/tclUnixInit.c15
3 files changed, 34 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 026141e..fec8f4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-02-17 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * tests/unixInit.test: unixInit-7.1
+ * unix/tclUnixInit.c (TclpInitPlatform): ensure the std fds exist
+ to prevent crash condition [Bug #772288]
+
2004-02-16 Jeff Hobbs <jeffh@ActiveState.com>
* generic/tclCmdMZ.c (TclTraceExecutionObjCmd)
diff --git a/tests/unixInit.test b/tests/unixInit.test
index f7b5a39..0225e3c 100644
--- a/tests/unixInit.test
+++ b/tests/unixInit.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: unixInit.test,v 1.30.2.3 2003/11/10 20:32:34 dgp Exp $
+# RCS: @(#) $Id: unixInit.test,v 1.30.2.4 2004/02/17 23:46:53 hobbs Exp $
package require tcltest 2
namespace import -force ::tcltest::*
@@ -354,6 +354,19 @@ test unixInit-5.1 {Tcl_Init} {emptyTest unixOnly} {
test unixInit-6.1 {Tcl_SourceRCFile} {emptyTest unixOnly} {
} {}
+test unixInit-7.1 {closed standard channel: Bug 772288} -body {
+ set tclsh [interpreter]
+ makeFile {puts [open /dev/null]} crash.tcl
+ makeFile [subst -nocommands {
+ close stdin
+ exec $tclsh crash.tcl
+ }] crashtest.tcl
+ exec $tclsh crashtest.tcl
+} -cleanup {
+ removeFile crash.tcl
+ removeFile crashtest.tcl
+} -returnCodes 0
+
# cleanup
if {[info exists oldlibrary]} {
set env(TCL_LIBRARY) $oldlibrary
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index ff033ee..d0dfd28 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclUnixInit.c,v 1.34.2.2 2003/11/10 20:32:34 dgp Exp $
+ * RCS: @(#) $Id: tclUnixInit.c,v 1.34.2.3 2004/02/17 23:46:54 hobbs Exp $
*/
#if defined(HAVE_CFBUNDLE)
@@ -170,6 +170,19 @@ TclpInitPlatform()
tclPlatform = TCL_PLATFORM_UNIX;
/*
+ * Make sure, that the standard FDs exist. [Bug 772288]
+ */
+ 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