wishCon 0.1 (98/04/10) ====================== Introduction ------------ wishCon implements native console support for Windows. o The new executable 'wishc80.exe' can be executed in a console window (cmd.exe or command.exe) und uses this console window for input and output. o You can use 'wishc80.exe' and 'wish80.exe' with input, output, error redirection. (e.g. 'wish80.exe myprog.tcl >myprog.log') o wishc80.exe can be used by emacs tcl-mode to execute tcl scripts. (just make a copy of wishc80.exe named wish.exe) Compiling and installing ------------------------ wishCon is a patch to tcl/tk source. To compile you have to: o Get Tcl8.0p2 and Tk8.0p2 source o Apply patches to tcl and tk if you have a patch program else copy files from tcl8.0, tk8.0 subdirectories to tcl and tk directories o Compile tcl/tk as usual o Copy dll's and exe's over old versions If you have no C-Compiler: o Get precompiled version of wishCon Changes in wish behaviour ------------------------- o Wish does not open a console window if it detects valid stdin, stdout or stderr handles. No console window appears if you redirect any of them. o If you run wish without filename and redirect stdout but not stdin, wish will terminate immediatly because there is no input available. o Blocking mode of stdin can be toggled. o File events on stdin can be used. Bugs, Restrictions ------------------ o wishc80.exe will not work with win32s, because win32s does not support pipes. o When stdin is in blocking mode and 'gets' is called wish blocks until a line of input is available. Meanwhile messages are dispatched to get window redraws. This may result in strange behaviour, because some events handled by Windows are processed immediatly (e.g. redraw,quit) and events processed by wish are queued. o Terminating wishc does not terminate wish if wishc was started with a filename. when wishc is closed it closes stdin, stdout and stderr of wishc. wish does not abort if stdin, stdout or stderr are closed, but you get errors like 'error writing "file44": broken pipe'. Tested Platforms, Compilers --------------------------- I compiled with Visual C 1.5+4.0. It Works on Win95 and NT. Due to restrictions in win32s wishc80 won't work with Win3x. When not using console or redirection this modified version should work with Win3x (i had no Win3x for testing available) If anyone has a Borland Compiler i would be interested if it compiles too (you must adapt tk8.0/win/makefile.bc). Implementation Details ---------------------- o Windows applications can have either a console (console application) or windows (gui application). o A gui application can have inherited stdin,stdout and stderr handles but these can only be files or pipes. o A console application which transfers all data from stdin,stdout and stderr through pipes to a gui application can simulate a console for the gui application. o Windows has no select() nor can it send a Message when input is available in anonymous pipes, so an application blocks if a pipe has no input available when using ReadFile(). o Calling PeekNamedPipe() periodically is very inefficient (busy wait). o If an application uses multiple threads only the reading thread blocks. o If a thread is created to read the stdin pipe it can block until a line is available. It then sends a WM_USER message to the main thread to wake up the main thread which then copies the data which is already read. o No one else can access this pipe (even GetFileType() blocks other threads (NT only)). o If stdin is a pipe it must not be closed or inherited to a child process. o Both applications should recognize when the other side is terminated. o modified files in tcl/tk source: tcl80.dll: tclWinChan.c: nearly everything enhanced (BufferedInputProc, FileInputProc, FileSetupProc, FileCheckProc, FileCloseProc, FileGetHandleProc, Tcl_MakeFileChannel) wish80.exe: winMain.c: check for STD_*_HANDLEs and create TkConsole or use handles tkMain.c: write result to stdout if available tk80.dll: tkWinInit.c: write initialisation error to stderr if available wishc80.exe: new winCon.c: new License ------- Copyright (C) 1998 by Kai Morich The author hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. Availability ------------ wishCon source is available at ftp.neosoft.com/pub/tcl/sorted/devel/wishCon-0.1.tar.gz or a precompiled version at ftp.neosoft.com/pub/tcl/sorted/devel/wishCon-0.1-bin.tar.gz -- Kai Morich