945
946
947
948
949
950
951
952
953
954
955
956
957
958
|
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
|
+
+
|
int result, applType, createFlags;
Tcl_DString cmdLine; /* Complete command line (TCHAR). */
STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo;
SECURITY_ATTRIBUTES secAtts;
HANDLE hProcess, h, inputHandle, outputHandle, errorHandle;
char execPath[MAX_PATH * TCL_UTF_MAX];
const char *valPtr;
int waitMS = 5000;
WinFile *filePtr;
PipeInit();
applType = ApplicationType(interp, argv[0], execPath);
if (applType == APPL_NONE) {
return TCL_ERROR;
|
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
|
/*
* "When an application spawns a process repeatedly, a new thread instance
* will be created for each process but the previous instances may not be
* cleaned up. This results in a significant virtual memory loss each time
* the process is spawned. If there is a WaitForInputIdle() call between
* CreateProcess() and CloseHandle(), the problem does not occur." PSS ID
* Number: Q124121
*
* Value of tcl_platform(WaitForInputIdle) if present allows to fine tune
* the maximum wait time here, since processes which don't deal with the
* message queue otherwise get always the default 5 second penalty.
*/
valPtr = Tcl_GetVar2(interp, "tcl_platform", "WaitForInputIdle",
TCL_GLOBAL_ONLY);
if (valPtr != NULL) {
int ms;
if (Tcl_GetInt(NULL, valPtr, &ms) == TCL_OK) {
waitMS = ms;
}
}
if (waitMS > 0) {
WaitForInputIdle(procInfo.hProcess, 5000);
WaitForInputIdle(procInfo.hProcess, waitMS);
}
CloseHandle(procInfo.hThread);
*pidPtr = (Tcl_Pid) procInfo.hProcess;
if (*pidPtr != 0) {
TclWinAddProcess(procInfo.hProcess, procInfo.dwProcessId);
}
result = TCL_OK;
|