Changeset 36182 in vbox for trunk/src/VBox
- Timestamp:
- Mar 7, 2011 10:35:35 AM (14 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r35907 r36182 5 5 6 6 /* 7 * Copyright (C) 2007-201 0Oracle Corporation7 * Copyright (C) 2007-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 591 591 } 592 592 } 593 #ifdef RT_OS_WINDOWS594 /*595 * Make sure only one instance of VBoxService runs at a time. Create a596 * global mutex for that. Do not use a global namespace ("Global\\") for597 * mutex name here, will blow up NT4 compatibility!598 */599 /** @todo r=bird: Use Global\\ prefix or this serves no purpose on terminal servers. */600 HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, VBOXSERVICE_NAME);601 if ( hMutexAppRunning != NULL602 && GetLastError() == ERROR_ALREADY_EXISTS)603 {604 VBoxServiceError("%s is already running! Terminating.", g_pszProgName);605 606 /* Close the mutex for this application instance. */607 CloseHandle(hMutexAppRunning);608 hMutexAppRunning = NULL;609 610 /** @todo r=bird: How does this cause us to terminate? Btw. Why do611 * we do this before parsing parameters? 'VBoxService --help'612 * and 'VBoxService --version' won't work now when the service613 * is running... */614 }615 #endif616 593 617 594 /* … … 736 713 } while (psz && *++psz); 737 714 } 715 716 #ifdef RT_OS_WINDOWS 717 /* 718 * Make sure only one instance of VBoxService runs at a time. Create a 719 * global mutex for that. 720 */ 721 OSVERSIONINFOEX OSInfoEx; 722 RT_ZERO(OSInfoEx); 723 OSInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 724 725 HANDLE hMutexAppRunning; 726 if ( GetVersionEx((LPOSVERSIONINFO) &OSInfoEx) 727 && OSInfoEx.dwPlatformId == VER_PLATFORM_WIN32_NT 728 && OSInfoEx.dwMajorVersion >= 5 /* NT 5.0 a.k.a W2K */) 729 { 730 hMutexAppRunning = CreateMutex(NULL, FALSE, VBOXSERVICE_NAME_GLOBAL); 731 } 732 else 733 { 734 /* On older Windows OSes (like NT4) don't use the global namespace 735 * needed for terminal servers on Win2K+. */ 736 hMutexAppRunning = CreateMutex(NULL, FALSE, VBOXSERVICE_NAME); 737 } 738 if ( hMutexAppRunning != NULL 739 && GetLastError() == ERROR_ALREADY_EXISTS) 740 { 741 VBoxServiceError("%s is already running! Terminating.", g_pszProgName); 742 743 /* Close the mutex for this application instance. */ 744 CloseHandle(hMutexAppRunning); 745 hMutexAppRunning = NULL; 746 747 return RTEXITCODE_FAILURE; 748 } 749 #else /* !RT_OS_WINDOWS */ 750 /** @todo Add PID file creation here. */ 751 #endif /* RT_OS_WINDOWS */ 752 738 753 /* 739 754 * Check that at least one service is enabled. -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r35954 r36182 94 94 /** The service name (needed for mutex creation on Windows). */ 95 95 #define VBOXSERVICE_NAME "VBoxService" 96 #define VBOXSERVICE_NAME_GLOBAL "Global\\VBoxService" 96 97 97 98 #ifdef RT_OS_WINDOWS
Note:
See TracChangeset
for help on using the changeset viewer.