diff options
author | hobbs <hobbs@noemail.net> | 2004-02-17 23:50:37 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2004-02-17 23:50:37 (GMT) |
commit | c629f12fd337f2a08db87a4791e45f309560c265 (patch) | |
tree | 13073fc7f4d5e3dedde22bac361daff703a1eebd /unix/tclUnixInit.c | |
parent | 1353a6acbbcc5353c696a65155bf8f57d200e681 (diff) | |
download | tcl-c629f12fd337f2a08db87a4791e45f309560c265.zip tcl-c629f12fd337f2a08db87a4791e45f309560c265.tar.gz tcl-c629f12fd337f2a08db87a4791e45f309560c265.tar.bz2 |
* tests/unixInit.test (unixInit-7.1):
* unix/tclUnixInit.c (TclpInitPlatform): ensure the std fds exist
to prevent crash condition [Bug #772288]
FossilOrigin-Name: 2f989b379a0ae888fa1f0a15f1a6f6cee5879da1
Diffstat (limited to 'unix/tclUnixInit.c')
-rw-r--r-- | unix/tclUnixInit.c | 16 |
1 files changed, 15 insertions, 1 deletions
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 |