Attachment "patch.txt" to
ticket [859820ffff]
added by
davygrvy
2004-01-21 16:18:32.
*** tclWinPipe.c 24 Dec 2003 04:18:23 -0000 1.39
--- tclWinPipe.c 20 Jan 2004 05:18:22 -0000 1.40
***************
*** 906,911 ****
--- 906,913 ----
{
ProcInfo *infoPtr;
+ PipeInit();
+
Tcl_MutexLock(&pipeMutex);
for (infoPtr = procList; infoPtr != NULL; infoPtr = infoPtr->nextPtr) {
if (infoPtr->hProcess == (HANDLE) pid) {
***************
*** 2485,2491 ****
int *statPtr,
int options)
{
! ProcInfo *infoPtr, **prevPtrPtr;
DWORD flags;
Tcl_Pid result;
DWORD ret, exitCode;
--- 2487,2493 ----
int *statPtr,
int options)
{
! ProcInfo *infoPtr = NULL, **prevPtrPtr;
DWORD flags;
Tcl_Pid result;
DWORD ret, exitCode;
***************
*** 2502,2508 ****
}
/*
! * Find the process on the process list.
*/
Tcl_MutexLock(&pipeMutex);
--- 2504,2510 ----
}
/*
! * Find the process and cut it from the process list.
*/
Tcl_MutexLock(&pipeMutex);
***************
*** 2510,2515 ****
--- 2512,2518 ----
for (infoPtr = procList; infoPtr != NULL;
prevPtrPtr = &infoPtr->nextPtr, infoPtr = infoPtr->nextPtr) {
if (infoPtr->hProcess == (HANDLE) pid) {
+ *prevPtrPtr = infoPtr->nextPtr;
break;
}
}
***************
*** 2539,2544 ****
--- 2542,2554 ----
if (ret == WAIT_TIMEOUT) {
*statPtr = 0;
if (options & WNOHANG) {
+ /*
+ * Re-insert this infoPtr back on the list.
+ */
+ Tcl_MutexLock(&pipeMutex);
+ infoPtr->nextPtr = procList;
+ procList = infoPtr;
+ Tcl_MutexUnlock(&pipeMutex);
return 0;
} else {
result = 0;
***************
*** 2601,2611 ****
}
/*
! * Remove the process from the process list and close the process handle.
*/
CloseHandle(infoPtr->hProcess);
- *prevPtrPtr = infoPtr->nextPtr;
ckfree((char*)infoPtr);
return result;
--- 2611,2620 ----
}
/*
! * Officially close the process handle.
*/
CloseHandle(infoPtr->hProcess);
ckfree((char*)infoPtr);
return result;