diff options
author | davygrvy <davygrvy@pobox.com> | 2002-12-04 03:59:16 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@pobox.com> | 2002-12-04 03:59:16 (GMT) |
commit | 08fd8ff5e9e7758d796135d08f7b801817ada3f1 (patch) | |
tree | 421ad51a976aae5d589bdba7e8fb98974b4cc60f /win/tclWinPipe.c | |
parent | a3ffa1319a78d7f38aacc6fc7d885a2f7d23e0df (diff) | |
download | tcl-08fd8ff5e9e7758d796135d08f7b801817ada3f1.zip tcl-08fd8ff5e9e7758d796135d08f7b801817ada3f1.tar.gz tcl-08fd8ff5e9e7758d796135d08f7b801817ada3f1.tar.bz2 |
* win/tclAppInit.c (sigHandler): Protect from trying to close a
NULL handle.
* win/tclWinPipe.c (PipeClose2Proc, TclpCreateProcess): Send a
real Win32 signal (CTRL_C_EVENT) when the read channel is brought
down to alert the child to close on its side. Start the process
with CREATE_NEW_PROCESS_GROUP to allow the ability to send these
signals. The following test case now brings down the child
without the use of an external [kill] command.
% set p [open "|[info name]" w+]
file8d5380
% pid $p
2876
% close $p <- now doesn't block in Tcl_WaitPid()
%
Diffstat (limited to 'win/tclWinPipe.c')
-rw-r--r-- | win/tclWinPipe.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 8a6fc59..9de247c 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPipe.c,v 1.27 2002/11/26 22:35:20 davygrvy Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.28 2002/12/04 03:59:17 davygrvy Exp $ */ #include "tclWinInt.h" @@ -1143,7 +1143,7 @@ TclpCreateProcess( if (TclWinGetPlatformId() == VER_PLATFORM_WIN32_NT) { if (HasConsole()) { - createFlags = 0; + createFlags = CREATE_NEW_PROCESS_GROUP; } else if (applType == APPL_DOS) { /* * Under NT, 16-bit DOS applications will not run unless they @@ -1162,7 +1162,7 @@ TclpCreateProcess( } } else { if (HasConsole()) { - createFlags = 0; + createFlags = CREATE_NEW_PROCESS_GROUP; } else { createFlags = DETACHED_PROCESS; } @@ -1852,6 +1852,19 @@ PipeClose2Proc( errorCode = 0; if ((!flags || (flags == TCL_CLOSE_READ)) && (pipePtr->readFile != NULL)) { + + /* + * Send the console group a notification of close. We assume + * the child is a console application, and that it will respond. + * It doesn't seem as though console mode applications that + * don't set a HandlerRoutine acknowledge this. + */ + + if (HasConsole() && pipePtr->numPids) { + GenerateConsoleCtrlEvent(CTRL_C_EVENT, + TclpGetPid(pipePtr->pidPtr[0])); + } + /* * Clean up the background thread if necessary. Note that this * must be done before we can close the file, since the |