Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: installer/src/installer-lib/process.cpp

Issue 6219169376763904: Issue #1686 - Kill iexplore.exe and AdblockplusEngine.exe processes from the installer (Closed)
Left Patch Set: Wait after everything is closed Created March 20, 2015, 5:31 a.m.
Right Patch Set: Log error Created April 13, 2015, 4:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « installer/src/installer-lib/process.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include <stdexcept> 1 #include <stdexcept>
2 #include <functional> 2 #include <functional>
3 #include <wctype.h> 3 #include <wctype.h>
4 // <thread> is C++11, but implemented in VS2012 4 // <thread> is C++11, but implemented in VS2012
5 #include <thread> 5 #include <thread>
6 6
7 #include "installer-lib.h" 7 #include "installer-lib.h"
8 #include "process.h" 8 #include "process.h"
9 #include "handle.h" 9 #include "handle.h"
10 #include "session.h" 10 #include "session.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 * The present use of this method is not closing dozens of applications, so delay performance is not critical. 209 * The present use of this method is not closing dozens of applications, so delay performance is not critical.
210 * 210 *
211 * \return 211 * \return
212 * The negation of is_running. 212 * The negation of is_running.
213 * If is_running() was true at the beginning, then this function will have run refresh() before returning. 213 * If is_running() was true at the beginning, then this function will have run refresh() before returning.
214 * 214 *
215 * \sa 215 * \sa
216 * - MSDN [WM_QUERYENDSESSION message](http://msdn.microsoft.com/en-us/library/ windows/desktop/aa376890%28v=vs.85%29.aspx) 216 * - MSDN [WM_QUERYENDSESSION message](http://msdn.microsoft.com/en-us/library/ windows/desktop/aa376890%28v=vs.85%29.aspx)
217 * - MSDN [WM_ENDSESSION message](http://msdn.microsoft.com/en-us/library/windo ws/desktop/aa376889%28v=vs.85%29.aspx) 217 * - MSDN [WM_ENDSESSION message](http://msdn.microsoft.com/en-us/library/windo ws/desktop/aa376889%28v=vs.85%29.aspx)
218 */ 218 */
219 bool ProcessCloser::ShutDown() 219 bool ProcessCloser::ShutDown(ImmediateSession& session)
220 { 220 {
221 /* 221 /*
222 * If we're not running, we don't need to shut down. 222 * If we're not running, we don't need to shut down.
223 */ 223 */
224 if ( ! IsRunning() ) 224 if ( ! IsRunning() )
225 { 225 {
226 return true ; 226 return true ;
227 } 227 }
228 228
229 /* 229 /*
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 /* 273 /*
274 * Send WM_CLOSE to every admissible window. 274 * Send WM_CLOSE to every admissible window.
275 */ 275 */
276 send_message m( WM_CLOSE, 0, 0 ) ; 276 send_message m( WM_CLOSE, 0, 0 ) ;
277 iterate_our_windows( m ) ; 277 iterate_our_windows( m ) ;
278 } 278 }
279 break ; 279 break ;
280 280
281 case 4: 281 case 4:
282 /* 282 /*
283 * We're out of ways to try to shut down. Oh well. Take cover. It gets viol ent here. 283 * Oh well. Take cover. It gets violent here. Try to kill all matching proc esses.
Eric 2015/03/20 08:53:16 Should restore the first half of the comment to it
284 */ 284 */
285 for (auto it = pid_set.begin(); it != pid_set.end(); ++it) 285 for (auto it = pid_set.begin(); it != pid_set.end(); ++it)
286 { 286 {
287 HANDLE tmpHandle = OpenProcess(PROCESS_TERMINATE, FALSE, *it); 287 HANDLE tmpHandle = OpenProcess(PROCESS_TERMINATE, FALSE, *it);
288 if (!tmpHandle) continue; 288 if (!tmpHandle)
289 {
290 std::ostringstream stream;
291 stream << "Can't open process for termination. Error: " << GetLastErro r();
Eric 2015/05/14 15:09:25 This message should indicate a warning rather than
292 session.Log(stream.str());
293 continue;
294 }
289 Windows_Handle procHandle(tmpHandle); 295 Windows_Handle procHandle(tmpHandle);
290 TerminateProcess(tmpHandle, 0); 296 if (!TerminateProcess(tmpHandle, 0))
Eric 2015/03/20 08:53:16 Given how unreliable it's turning out to be to shu
sergei 2015/04/02 08:04:09 Merely want to add that MSI is already configured
sergei 2015/04/02 08:04:09 As well as it would be good to log the state to be
Eric 2015/05/14 15:09:25 The process 'msiexec.exe' runs with elevated privi
297 {
298 std::ostringstream stream;
299 stream << "Can't terminate process. Error: " << GetLastError();
300 session.Log(stream.str());
301 }
291 } 302 }
292 break; 303 break;
293 304
294 default: 305 default:
306 // We're out of ways to try to shut down.
295 return false; 307 return false;
296 } 308 }
297 309
298 /* 310 /*
299 * Wait loop. 311 * Wait loop.
300 */ 312 */
301 for ( unsigned int j = 0 ; j < 50 ; ++ j ) 313 for ( unsigned int j = 0 ; j < 50 ; ++ j )
302 { 314 {
303 std::this_thread::sleep_for( std::chrono::milliseconds( 30 ) ) ; 315 std::this_thread::sleep_for( std::chrono::milliseconds( 30 ) ) ;
304 Refresh() ; 316 Refresh() ;
305 if ( ! IsRunning() ) 317 if ( ! IsRunning() )
306 { 318 {
307 return true ; 319 return true ;
308 } 320 }
309 } 321 }
310 // Assert is_running() 322 // Assert is_running()
311 } 323 }
312 // No control path leaves the for-loop. 324 // No control path leaves the for-loop.
313 } ; 325 } ;
314 326
LEFTRIGHT

Powered by Google App Engine
This is Rietveld