summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorstanton <stanton>1999-03-11 00:19:23 (GMT)
committerstanton <stanton>1999-03-11 00:19:23 (GMT)
commit959ef2397770f8b6b7319b28c4cee7ef60ba6ac4 (patch)
tree5395cacc9a5253542d062dfcb57426a2721a541b /win
parent17d56fd5b956aa638c25faaac51a8856ee8f51d7 (diff)
downloadtcl-959ef2397770f8b6b7319b28c4cee7ef60ba6ac4.zip
tcl-959ef2397770f8b6b7319b28c4cee7ef60ba6ac4.tar.gz
tcl-959ef2397770f8b6b7319b28c4cee7ef60ba6ac4.tar.bz2
* win/tclWinPipe.c:
* generic/tclInt.decls: Added TclWinAddProcess to make it possible for expect to use Tcl_WaitForPid(). This patch is from Gordon Chaffee. * mac/tclMacPort.h: * win/tclWinInit.c: * unix/tclUnixPort.h: * generic/tclAsync.c: Added TclpAsyncMark to fix bug in async handling on Windows where async events don't wake up the event loop. This patch comes from Gordon Chaffee. * generic/tcl.decls: Fixed declarations of reserved slots.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinInit.c43
-rw-r--r--win/tclWinPipe.c44
2 files changed, 75 insertions, 12 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 6173def..2a470df 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinInit.c,v 1.12 1999/02/02 18:36:31 stanton Exp $
+ * RCS: @(#) $Id: tclWinInit.c,v 1.13 1999/03/11 00:19:24 stanton Exp $
*/
#include "tclInt.h"
@@ -82,6 +82,12 @@ static char* processors[NUMPROCESSORS] = {
#include "tclInitScript.h"
+/*
+ * Thread id used for asynchronous notification from signal handlers.
+ */
+
+static DWORD threadId;
+
/*
*----------------------------------------------------------------------
@@ -279,6 +285,13 @@ TclPlatformInit(interp)
}
Tcl_DStringFree(&ds);
+
+ /*
+ * Save the current thread id so an async signal handler can poke
+ * the right thread using TclpAyncMark.
+ */
+
+ threadId = GetCurrentThreadId();
}
/*
@@ -396,3 +409,31 @@ Tcl_SourceRCFile(interp)
Tcl_DStringFree(&temp);
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpAsyncMark --
+ *
+ * Wake up the main thread from a signal handler.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Sends a message to the main thread.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclpAsyncMark(async)
+ Tcl_AsyncHandler async; /* Token for handler. */
+{
+ /*
+ * Need a way to kick the Windows event loop and tell it to go look at
+ * asynchronous events.
+ */
+
+ PostThreadMessage(threadId, WM_USER, 0, 0);
+}
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 76695e0..8194f64 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.3 1998/09/14 18:40:20 stanton Exp $
+ * RCS: @(#) $Id: tclWinPipe.c,v 1.4 1999/03/11 00:19:24 stanton Exp $
*/
#include "tclWinInt.h"
@@ -998,11 +998,7 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
}
*pidPtr = (Tcl_Pid) procInfo.hProcess;
if (*pidPtr != 0) {
- ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
- procPtr->hProcess = procInfo.hProcess;
- procPtr->dwProcessId = procInfo.dwProcessId;
- procPtr->nextPtr = procList;
- procList = procPtr;
+ TclWinAddProcess(procInfo.hProcess, procInfo.dwProcessId);
}
result = TCL_OK;
}
@@ -1303,11 +1299,7 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
*pidPtr = (Tcl_Pid) procInfo.hProcess;
if (*pidPtr != 0) {
- ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
- procPtr->hProcess = procInfo.hProcess;
- procPtr->dwProcessId = procInfo.dwProcessId;
- procPtr->nextPtr = procList;
- procList = procPtr;
+ TclWinAddProcess(procInfo.hProcess, procInfo.dwProcessId);
}
result = TCL_OK;
@@ -2416,6 +2408,36 @@ Tcl_WaitPid(pid, statPtr, options)
/*
*----------------------------------------------------------------------
*
+ * TclWinAddProcess --
+ *
+ * Add a process to the process list so that we can use
+ * Tcl_WaitPid on the process.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * Adds the specified process handle to the process list so
+ * Tcl_WaitPid knows about it.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclWinAddProcess(hProcess, id)
+ HANDLE hProcess; /* Handle to process */
+ DWORD id; /* Global process identifier */
+{
+ ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
+ procPtr->hProcess = hProcess;
+ procPtr->dwProcessId = id;
+ procPtr->nextPtr = procList;
+ procList = procPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_PidObjCmd --
*
* This procedure is invoked to process the "pid" Tcl command.