diff options
author | hobbs <hobbs> | 2004-02-17 23:50:38 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2004-02-17 23:50:38 (GMT) |
commit | 9c40be080e14950efdca421aea648fc80664787d (patch) | |
tree | 13073fc7f4d5e3dedde22bac361daff703a1eebd | |
parent | a09e7d11eb23fc3178525780675d000298e8ccff (diff) | |
download | tcl-9c40be080e14950efdca421aea648fc80664787d.zip tcl-9c40be080e14950efdca421aea648fc80664787d.tar.gz tcl-9c40be080e14950efdca421aea648fc80664787d.tar.bz2 |
* tests/unixInit.test (unixInit-7.1):
* unix/tclUnixInit.c (TclpInitPlatform): ensure the std fds exist
to prevent crash condition [Bug #772288]
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | tests/unixInit.test | 15 | ||||
-rw-r--r-- | unix/tclUnixInit.c | 16 |
3 files changed, 42 insertions, 9 deletions
@@ -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-17 Donal K. Fellows <donal.k.fellows@man.ac.uk> * generic/tclCompCmds.c (TclCompileSwitchCmd): Bozo mistake in @@ -739,14 +745,14 @@ 2003-11-10 Don Porter <dgp@users.sourceforge.net> - * unix/tclUnixInit.c (TclpInitLibraryPath): - * win/tclWinInit.c (TclpInitLibraryPath): Fix for [Bug 832657] - that should not run afoul of startup constraints. + * unix/tclUnixInit.c (TclpInitLibraryPath): + * win/tclWinInit.c (TclpInitLibraryPath): Fix for [Bug 832657] + that should not run afoul of startup constraints. - * library/dde/pkgIndex.tcl: Added safeguards so that registry - * library/reg/pkgIndex.tcl: and dde packages are not offered - * win/tclWinDde.c: on non-Windows platforms. Bumped to - * win/tclWinReg.c: registry 1.1.3 and dde 1.3. + * library/dde/pkgIndex.tcl: Added safeguards so that registry + * library/reg/pkgIndex.tcl: and dde packages are not offered + * win/tclWinDde.c: on non-Windows platforms. Bumped to + * win/tclWinReg.c: registry 1.1.3 and dde 1.3. * win/Makefile.in: * win/configure.in: * win/makefile.bc: diff --git a/tests/unixInit.test b/tests/unixInit.test index 4ec31a5..9780738 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.31 2003/11/05 20:50:44 dgp Exp $ +# RCS: @(#) $Id: unixInit.test,v 1.32 2004/02/17 23:50:39 hobbs Exp $ package require tcltest 2 namespace import -force ::tcltest::* @@ -353,6 +353,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 779437c..39a8138 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.37 2003/11/18 23:29:47 davygrvy Exp $ + * RCS: @(#) $Id: tclUnixInit.c,v 1.38 2004/02/17 23:50:39 hobbs Exp $ */ #if defined(HAVE_CFBUNDLE) @@ -174,6 +174,20 @@ TclpInitPlatform() #endif /* + * 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 |