Changeset 39202 in vbox for trunk/src/VBox
- Timestamp:
- Nov 4, 2011 11:07:23 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r38636 r39202 374 374 375 375 376 #ifdef RT_OS_WINDOWS 377 static BOOL WINAPI VBoxServiceConsoleControlHandler(DWORD dwCtrlType) 378 { 379 int rc = VINF_SUCCESS; 380 bool fEventHandled = FALSE; 381 switch (dwCtrlType) 382 { 383 /* User pressed CTRL+C or CTRL+BREAK or an external event was sent 384 * via GenerateConsoleCtrlEvent(). */ 385 case CTRL_BREAK_EVENT: 386 case CTRL_CLOSE_EVENT: 387 case CTRL_C_EVENT: 388 VBoxServiceVerbose(2, "ControlHandler: Received break/close event\n"); 389 rc = VBoxServiceStopServices(); 390 fEventHandled = TRUE; 391 break; 392 default: 393 break; 394 /** @todo Add other events here. */ 395 } 396 397 if (RT_FAILURE(rc)) 398 VBoxServiceError("ControlHandler: Event %ld handled with error rc=%Rrc\n", 399 dwCtrlType, rc); 400 return fEventHandled; 401 } 402 #endif /* RT_OS_WINDOWS */ 403 404 376 405 /** 377 406 * Starts the service. … … 555 584 RTSemEventDestroy(g_hEvtWindowsService); 556 585 g_hEvtWindowsService = NIL_RTSEMEVENT; 557 558 586 #else 559 587 /* … … 864 892 * and return immediately. 865 893 */ 894 #ifdef RT_OS_WINDOWS 895 # ifndef RT_OS_NT4 896 /* Install console control handler. */ 897 if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)VBoxServiceConsoleControlHandler, TRUE /* Add handler */)) 898 { 899 VBoxServiceError("Unable to add console control handler, error=%ld\n", GetLastError()); 900 /* Just skip this error, not critical. */ 901 } 902 # endif /* !RT_OS_NT4 */ 903 #endif /* RT_OS_WINDOWS */ 866 904 rc = VBoxServiceStartServices(); 867 905 rcExit = RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 868 906 if (RT_SUCCESS(rc)) 869 907 VBoxServiceMainWait(); 908 #ifdef RT_OS_WINDOWS 909 # ifndef RT_OS_NT4 910 /* Uninstall console control handler. */ 911 if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)NULL, FALSE /* Remove handler */)) 912 { 913 VBoxServiceError("Unable to remove console control handler, error=%ld\n", GetLastError()); 914 /* Just skip this error, not critical. */ 915 } 916 # endif /* !RT_OS_NT4 */ 917 #else /* !RT_OS_WINDOWS */ 918 /* On Windows - since we're running as a console application - we already stopped all services 919 * through the console control handler. So only do the stopping of services here on other platforms 920 * where the break/shutdown/whatever signal was just received. */ 870 921 VBoxServiceStopServices(); 922 #endif /* RT_OS_WINDOWS */ 871 923 } 872 924 VBoxServiceReportStatus(VBoxGuestFacilityStatus_Terminated);
Note:
See TracChangeset
for help on using the changeset viewer.