@@ -94,7 +94,7 @@ string findSeleniumDriver(const string &driver) {
94
94
return bo::to_utf8 (buffer.get ());
95
95
}
96
96
97
- Desktop::ProcessInTheJob explorerInfo, driverInfo;
97
+ Desktop::ProcessInTheJob driverInfo;
98
98
HANDLE jobHandle = 0 ;
99
99
HDESK desktopHandle = 0 ;
100
100
@@ -107,7 +107,7 @@ void cleanUp() {
107
107
108
108
auto topWindows = Desktop::allTopLevelWindows (desktopName);
109
109
LOGD << " Top level windows in the headless desktop: " << topWindows.size ();
110
-
110
+
111
111
for (HWND w : topWindows) {
112
112
LOGT << (bo::format (" Quitting the '%1%' top level window." ) % w).str ();
113
113
@@ -119,8 +119,6 @@ void cleanUp() {
119
119
LOGD << " Top level windows after sending the quit msg: "
120
120
<< Desktop::allTopLevelWindows (desktopName).size ();
121
121
122
- Process::wait (explorerInfo.processInfo .hProcess );
123
-
124
122
if (jobHandle) {
125
123
LOGD << " Going to close the job object." ;
126
124
CloseHandle (jobHandle);
@@ -180,41 +178,22 @@ int _tmain(int argc, _TCHAR* argv[])
180
178
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)ctrlHandler, TRUE );
181
179
182
180
desktopHandle = Desktop::create (desktopName);
183
- explorerInfo = Desktop::createProcessInTheJob (
181
+
182
+ driverInfo = Desktop::createProcessInTheJob (
184
183
desktopName,
185
- " c:\\ Windows\\ explorer.exe" );
184
+ selDriverPath,
185
+ cmdLine);
186
186
187
- if (explorerInfo .status == explorerInfo .COULD_NOT_ASSIGN_JOB ) {
187
+ if (driverInfo .status == driverInfo .COULD_NOT_ASSIGN_JOB ) {
188
188
LOGW << " WARN: Could not use Windows job objects! "
189
189
" That means the cleaning-up procedure might not be reliable." ;
190
- ResumeThread (explorerInfo .processInfo .hThread );
190
+ ResumeThread (driverInfo .processInfo .hThread );
191
191
}
192
- CloseHandle (explorerInfo.processInfo .hThread );
193
- jobHandle = explorerInfo.jobHandle ;
194
-
195
- Sleep (2000 );
196
-
197
- if (explorerInfo.status == explorerInfo.COULD_NOT_ASSIGN_JOB ) {
198
- auto pi = Desktop::createProcess (
199
- desktopName,
200
- selDriverPath,
201
- cmdLine);
202
-
203
- driverInfo = Desktop::ProcessInTheJob (
204
- Desktop::ProcessInTheJob::COULD_NOT_ASSIGN_JOB,
205
- 0 ,
206
- pi );
207
- }
208
- else
209
- driverInfo = Desktop::createProcessInTheJob (
210
- desktopName,
211
- selDriverPath,
212
- cmdLine,
213
- jobHandle);
192
+ jobHandle = driverInfo.jobHandle ;
214
193
215
194
CloseHandle (driverInfo.processInfo .hThread );
216
-
217
195
Process::wait (driverInfo.processInfo .hProcess );
196
+ CloseHandle (driverInfo.processInfo .hProcess );
218
197
219
198
cleanUp ();
220
199
}
0 commit comments