VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp@ 29250

Last change on this file since 29250 was 29202, checked in by vboxsync, 15 years ago

VBoxService: Don't terminate if some HGCM host service is not available on the host.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.9 KB
Line 
1/* $Id: VBoxService.cpp 29202 2010-05-07 12:38:59Z vboxsync $ */
2/** @file
3 * VBoxService - Guest Additions Service Skeleton.
4 */
5
6/*
7 * Copyright (C) 2007-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23/** @todo LOG_GROUP*/
24#ifndef _MSC_VER
25# include <unistd.h>
26#endif
27#include <errno.h>
28#ifndef RT_OS_WINDOWS
29# include <signal.h>
30#endif
31
32#include "product-generated.h"
33#include <iprt/asm.h>
34#include <iprt/buildconfig.h>
35#include <iprt/initterm.h>
36#include <iprt/path.h>
37#include <iprt/string.h>
38#include <iprt/stream.h>
39#include <iprt/thread.h>
40
41#include <VBox/VBoxGuestLib.h>
42#include <VBox/log.h>
43
44#include "VBoxServiceInternal.h"
45
46
47/*******************************************************************************
48* Global Variables *
49*******************************************************************************/
50/** The program name (derived from argv[0]). */
51char *g_pszProgName = (char *)"";
52/** The current verbosity level. */
53int g_cVerbosity = 0;
54/** The default service interval (the -i | --interval) option). */
55uint32_t g_DefaultInterval = 0;
56/** Shutdown the main thread. (later, for signals.) */
57bool volatile g_fShutdown;
58
59/**
60 * The details of the services that has been compiled in.
61 */
62static struct
63{
64 /** Pointer to the service descriptor. */
65 PCVBOXSERVICE pDesc;
66 /** The worker thread. NIL_RTTHREAD if it's the main thread. */
67 RTTHREAD Thread;
68 /** Shutdown indicator. */
69 bool volatile fShutdown;
70 /** Indicator set by the service thread exiting. */
71 bool volatile fStopped;
72 /** Whether the service was started or not. */
73 bool fStarted;
74 /** Whether the service is enabled or not. */
75 bool fEnabled;
76} g_aServices[] =
77{
78#ifdef VBOXSERVICE_CONTROL
79 { &g_Control, NIL_RTTHREAD, false, false, false, true },
80#endif
81#ifdef VBOXSERVICE_TIMESYNC
82 { &g_TimeSync, NIL_RTTHREAD, false, false, false, true },
83#endif
84#ifdef VBOXSERVICE_CLIPBOARD
85 { &g_Clipboard, NIL_RTTHREAD, false, false, false, true },
86#endif
87#ifdef VBOXSERVICE_VMINFO
88 { &g_VMInfo, NIL_RTTHREAD, false, false, false, true },
89#endif
90#ifdef VBOXSERVICE_EXEC
91 { &g_Exec, NIL_RTTHREAD, false, false, false, true },
92#endif
93#ifdef VBOXSERVICE_CPUHOTPLUG
94 { &g_CpuHotPlug, NIL_RTTHREAD, false, false, false, true },
95#endif
96#ifdef VBOXSERVICE_MANAGEMENT
97# ifdef VBOX_WITH_MEMBALLOON
98 { &g_MemBalloon, NIL_RTTHREAD, false, false, false, true },
99# endif
100 { &g_VMStatistics, NIL_RTTHREAD, false, false, false, true },
101#endif
102};
103
104
105/**
106 * Displays the program usage message.
107 *
108 * @returns 1.
109 */
110static int VBoxServiceUsage(void)
111{
112 RTPrintf("usage: %s [-f|--foreground] [-v|--verbose] [-i|--interval <seconds>]\n"
113 " [--disable-<service>] [--enable-<service>] [-h|-?|--help]\n", g_pszProgName);
114#ifdef RT_OS_WINDOWS
115 RTPrintf(" [-r|--register] [-u|--unregister]\n");
116#endif
117 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
118 RTPrintf(" %s\n", g_aServices[j].pDesc->pszUsage);
119 RTPrintf("\n"
120 "Options:\n"
121 " -i | --interval The default interval.\n"
122 " -f | --foreground Don't daemonzie the program. For debugging.\n"
123 " -v | --verbose Increment the verbosity level. For debugging.\n"
124 " -h | -? | --help Show this message and exit with status 1.\n"
125 );
126#ifdef RT_OS_WINDOWS
127 RTPrintf(" -r | --register Installs the service.\n"
128 " -u | --unregister Uninstall service.\n");
129#endif
130
131 RTPrintf("\n"
132 "Service specific options:\n");
133 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
134 {
135 RTPrintf(" --enable-%-10s Enables the %s service. (default)\n", g_aServices[j].pDesc->pszName, g_aServices[j].pDesc->pszName);
136 RTPrintf(" --disable-%-9s Disables the %s service.\n", g_aServices[j].pDesc->pszName, g_aServices[j].pDesc->pszName);
137 if (g_aServices[j].pDesc->pszOptions)
138 RTPrintf("%s", g_aServices[j].pDesc->pszOptions);
139 }
140 RTPrintf("\n"
141 " Copyright (C) 2009-" VBOX_C_YEAR " " VBOX_VENDOR "\n");
142
143 return 1;
144}
145
146
147/**
148 * Displays a syntax error message.
149 *
150 * @returns 1
151 * @param pszFormat The message text.
152 * @param ... Format arguments.
153 */
154int VBoxServiceSyntax(const char *pszFormat, ...)
155{
156 RTStrmPrintf(g_pStdErr, "%s: syntax error: ", g_pszProgName);
157
158 va_list va;
159 va_start(va, pszFormat);
160 RTStrmPrintfV(g_pStdErr, pszFormat, va);
161 va_end(va);
162
163 return 1;
164}
165
166
167/**
168 * Displays an error message.
169 *
170 * @returns 1
171 * @param pszFormat The message text.
172 * @param ... Format arguments.
173 */
174int VBoxServiceError(const char *pszFormat, ...)
175{
176 RTStrmPrintf(g_pStdErr, "%s: error: ", g_pszProgName);
177
178 va_list va;
179 va_start(va, pszFormat);
180 RTStrmPrintfV(g_pStdErr, pszFormat, va);
181 va_end(va);
182
183 va_start(va, pszFormat);
184 LogRel(("%s: Error: %N", g_pszProgName, pszFormat, &va));
185 va_end(va);
186
187 return 1;
188}
189
190
191/**
192 * Displays a verbose message.
193 *
194 * @returns 1
195 * @param pszFormat The message text.
196 * @param ... Format arguments.
197 */
198void VBoxServiceVerbose(int iLevel, const char *pszFormat, ...)
199{
200 if (iLevel <= g_cVerbosity)
201 {
202 RTStrmPrintf(g_pStdOut, "%s: ", g_pszProgName);
203 va_list va;
204 va_start(va, pszFormat);
205 RTStrmPrintfV(g_pStdOut, pszFormat, va);
206 va_end(va);
207
208 va_start(va, pszFormat);
209 LogRel(("%s: %N", g_pszProgName, pszFormat, &va));
210 va_end(va);
211 }
212}
213
214
215/**
216 * Gets a 32-bit value argument.
217 *
218 * @returns 0 on success, non-zero exit code on error.
219 * @param argc The argument count.
220 * @param argv The argument vector
221 * @param psz Where in *pi to start looking for the value argument.
222 * @param pi Where to find and perhaps update the argument index.
223 * @param pu32 Where to store the 32-bit value.
224 * @param u32Min The minimum value.
225 * @param u32Max The maximum value.
226 */
227int VBoxServiceArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max)
228{
229 if (*psz == ':' || *psz == '=')
230 psz++;
231 if (!*psz)
232 {
233 if (*pi + 1 >= argc)
234 return VBoxServiceSyntax("Missing value for the '%s' argument\n", argv[*pi]);
235 psz = argv[++*pi];
236 }
237
238 char *pszNext;
239 int rc = RTStrToUInt32Ex(psz, &pszNext, 0, pu32);
240 if (RT_FAILURE(rc) || *pszNext)
241 return VBoxServiceSyntax("Failed to convert interval '%s' to a number.\n", psz);
242 if (*pu32 < u32Min || *pu32 > u32Max)
243 return VBoxServiceSyntax("The timesync interval of %RU32 secconds is out of range [%RU32..%RU32].\n",
244 *pu32, u32Min, u32Max);
245 return 0;
246}
247
248
249/**
250 * The service thread.
251 *
252 * @returns Whatever the worker function returns.
253 * @param ThreadSelf My thread handle.
254 * @param pvUser The service index.
255 */
256static DECLCALLBACK(int) VBoxServiceThread(RTTHREAD ThreadSelf, void *pvUser)
257{
258 const unsigned i = (uintptr_t)pvUser;
259
260#ifndef RT_OS_WINDOWS
261 /*
262 * Block all signals for this thread. Only the main thread will handle signals.
263 */
264 sigset_t signalMask;
265 sigfillset(&signalMask);
266 pthread_sigmask(SIG_BLOCK, &signalMask, NULL);
267#endif
268
269 int rc = g_aServices[i].pDesc->pfnWorker(&g_aServices[i].fShutdown);
270 ASMAtomicXchgBool(&g_aServices[i].fShutdown, true);
271 RTThreadUserSignal(ThreadSelf);
272 return rc;
273}
274
275
276unsigned VBoxServiceGetStartedServices(void)
277{
278 unsigned iMain = ~0U;
279 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
280 if (g_aServices[j].fEnabled)
281 {
282 iMain = j;
283 break;
284 }
285
286 return iMain; /* Return the index of the main service (must always come last!). */
287}
288
289
290/**
291 * Starts the service.
292 *
293 * @returns VBox status code, errors are fully bitched.
294 *
295 * @param iMain The index of the service that belongs to the main
296 * thread. Pass ~0U if none does.
297 */
298int VBoxServiceStartServices(unsigned iMain)
299{
300 int rc;
301
302 /*
303 * Initialize the services.
304 */
305 VBoxServiceVerbose(2, "Initializing services ...\n");
306 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
307 if (g_aServices[j].fEnabled)
308 {
309 rc = g_aServices[j].pDesc->pfnInit();
310 if (RT_FAILURE(rc))
311 {
312 /*
313 * If a service uses some sort of HGCM host service
314 * which is not available on the host (maybe because the host
315 * is using an older VBox version), just disable that service
316 * here.
317 */
318 if (rc == VERR_HGCM_SERVICE_NOT_FOUND)
319 {
320 g_aServices[j].fEnabled = false;
321 VBoxServiceVerbose(0, "Service '%s' was disabled (because %Rrc)\n",
322 g_aServices[j].pDesc->pszName, rc);
323 }
324 else
325 {
326 VBoxServiceError("Service '%s' failed to initialize: %Rrc\n",
327 g_aServices[j].pDesc->pszName, rc);
328 return rc;
329 }
330 }
331 }
332
333 /*
334 * Start the service(s).
335 */
336 VBoxServiceVerbose(2, "Starting services ...\n");
337 rc = VINF_SUCCESS;
338 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
339 {
340 if ( !g_aServices[j].fEnabled
341 || j == iMain)
342 continue;
343
344 VBoxServiceVerbose(2, "Starting service '%s' ...\n", g_aServices[j].pDesc->pszName);
345 rc = RTThreadCreate(&g_aServices[j].Thread, VBoxServiceThread, (void *)(uintptr_t)j, 0,
346 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, g_aServices[j].pDesc->pszName);
347 if (RT_FAILURE(rc))
348 {
349 VBoxServiceError("RTThreadCreate failed, rc=%Rrc\n", rc);
350 break;
351 }
352 g_aServices[j].fStarted = true;
353
354 /* wait for the thread to initialize */
355 RTThreadUserWait(g_aServices[j].Thread, 60 * 1000);
356 if (g_aServices[j].fShutdown)
357 {
358 VBoxServiceError("Service '%s' failed to start!\n", g_aServices[j].pDesc->pszName);
359 rc = VERR_GENERAL_FAILURE;
360 }
361 }
362 if ( RT_SUCCESS(rc)
363 && iMain != ~0U)
364 {
365 /* The final service runs in the main thread. */
366 VBoxServiceVerbose(1, "Starting '%s' in the main thread\n", g_aServices[iMain].pDesc->pszName);
367 rc = g_aServices[iMain].pDesc->pfnWorker(&g_fShutdown);
368 if (rc != VINF_SUCCESS) /* Only complain if service returned an error. Otherwise the service is a one-timer. */
369 {
370 VBoxServiceError("Service '%s' stopped unexpected; rc=%Rrc\n", g_aServices[iMain].pDesc->pszName, rc);
371 }
372 }
373 return rc;
374}
375
376
377/**
378 * Stops and terminates the services.
379 *
380 * This should be called even when VBoxServiceStartServices fails so it can
381 * clean up anything that we succeeded in starting.
382 */
383int VBoxServiceStopServices(void)
384{
385 int rc = VINF_SUCCESS;
386
387 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
388 ASMAtomicXchgBool(&g_aServices[j].fShutdown, true);
389 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
390 if (g_aServices[j].fStarted)
391 g_aServices[j].pDesc->pfnStop();
392 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
393 if (g_aServices[j].fEnabled)
394 {
395 if (g_aServices[j].Thread != NIL_RTTHREAD)
396 {
397 VBoxServiceVerbose(2, "Waiting for service '%s' to stop ...\n", g_aServices[j].pDesc->pszName);
398 for (int i = 0; i < 30; i++) /* Wait 30 seconds in total */
399 {
400 rc = RTThreadWait(g_aServices[j].Thread, 1000 /* Wait 1 second */, NULL);
401 if (RT_SUCCESS(rc))
402 break;
403#ifdef RT_OS_WINDOWS
404 /* Notify SCM that it takes a bit longer ... */
405 VBoxServiceWinSetStatus(SERVICE_STOP_PENDING, i);
406#endif
407 }
408 if (RT_FAILURE(rc))
409 VBoxServiceError("Service '%s' failed to stop. (%Rrc)\n", g_aServices[j].pDesc->pszName, rc);
410 }
411 VBoxServiceVerbose(3, "Terminating service '%s' (%d) ...\n", g_aServices[j].pDesc->pszName, j);
412 g_aServices[j].pDesc->pfnTerm();
413 }
414
415 VBoxServiceVerbose(2, "Stopping services returned: rc=%Rrc\n", rc);
416 return rc;
417}
418
419
420#ifndef RT_OS_WINDOWS
421/*
422 * Block all important signals, then explicitly wait until one of these signal arrives.
423 */
424static void VBoxServiceWaitSignal(void)
425{
426 sigset_t signalMask;
427 int iSignal;
428 sigemptyset(&signalMask);
429 sigaddset(&signalMask, SIGHUP);
430 sigaddset(&signalMask, SIGINT);
431 sigaddset(&signalMask, SIGQUIT);
432 sigaddset(&signalMask, SIGABRT);
433 sigaddset(&signalMask, SIGTERM);
434 pthread_sigmask(SIG_BLOCK, &signalMask, NULL);
435 sigwait(&signalMask, &iSignal);
436 VBoxServiceVerbose(3, "VBoxServiceWaitSignal: Received signal %d\n", iSignal);
437}
438#endif /* !RT_OS_WINDOWS */
439
440
441int main(int argc, char **argv)
442{
443 int rc = VINF_SUCCESS;
444 /*
445 * Init globals and such.
446 */
447 RTR3Init();
448
449 /*
450 * Connect to the kernel part before daemonizing so we can fail
451 * and complain if there is some kind of problem. We need to initialize
452 * the guest lib *before* we do the pre-init just in case one of services
453 * needs do to some initial stuff with it.
454 */
455 VBoxServiceVerbose(2, "Calling VbgR3Init()\n");
456 rc = VbglR3Init();
457 if (RT_FAILURE(rc))
458 return VBoxServiceError("VbglR3Init failed with rc=%Rrc.\n", rc);
459
460 /* Do pre-init of services. */
461 g_pszProgName = RTPathFilename(argv[0]);
462 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
463 {
464 rc = g_aServices[j].pDesc->pfnPreInit();
465 if (RT_FAILURE(rc))
466 return VBoxServiceError("Service '%s' failed pre-init: %Rrc\n", g_aServices[j].pDesc->pszName);
467 }
468
469#ifdef RT_OS_WINDOWS
470 /* Make sure only one instance of VBoxService runs at a time. Create a global mutex for that.
471 Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */
472 HANDLE hMutexAppRunning = CreateMutex (NULL, FALSE, VBOXSERVICE_NAME);
473 if ( hMutexAppRunning != NULL
474 && GetLastError() == ERROR_ALREADY_EXISTS)
475 {
476 VBoxServiceError("%s is already running! Terminating.", g_pszProgName);
477
478 /* Close the mutex for this application instance. */
479 CloseHandle(hMutexAppRunning);
480 hMutexAppRunning = NULL;
481 }
482#endif
483
484 /*
485 * Parse the arguments.
486 */
487 bool fDaemonize = true;
488 bool fDaemonized = false;
489 for (int i = 1; i < argc; i++)
490 {
491 const char *psz = argv[i];
492 if (*psz != '-')
493 return VBoxServiceSyntax("Unknown argument '%s'\n", psz);
494 psz++;
495
496 /* translate long argument to short */
497 if (*psz == '-')
498 {
499 psz++;
500 size_t cch = strlen(psz);
501#define MATCHES(strconst) ( cch == sizeof(strconst) - 1 \
502 && !memcmp(psz, strconst, sizeof(strconst) - 1) )
503 if (MATCHES("foreground"))
504 psz = "f";
505 else if (MATCHES("verbose"))
506 psz = "v";
507 else if (MATCHES("help"))
508 psz = "h";
509 else if (MATCHES("interval"))
510 psz = "i";
511#ifdef RT_OS_WINDOWS
512 else if (MATCHES("register"))
513 psz = "r";
514 else if (MATCHES("unregister"))
515 psz = "u";
516#endif
517 else if (MATCHES("daemonized"))
518 {
519 fDaemonized = true;
520 continue;
521 }
522 else
523 {
524 bool fFound = false;
525
526 if (cch > sizeof("enable-") && !memcmp(psz, "enable-", sizeof("enable-") - 1))
527 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++)
528 if ((fFound = !RTStrICmp(psz + sizeof("enable-") - 1, g_aServices[j].pDesc->pszName)))
529 g_aServices[j].fEnabled = true;
530
531 if (cch > sizeof("disable-") && !memcmp(psz, "disable-", sizeof("disable-") - 1))
532 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++)
533 if ((fFound = !RTStrICmp(psz + sizeof("disable-") - 1, g_aServices[j].pDesc->pszName)))
534 g_aServices[j].fEnabled = false;
535
536 if (!fFound)
537 for (unsigned j = 0; !fFound && j < RT_ELEMENTS(g_aServices); j++)
538 {
539 rc = g_aServices[j].pDesc->pfnOption(NULL, argc, argv, &i);
540 fFound = rc == 0;
541 if (fFound)
542 break;
543 if (rc != -1)
544 return rc;
545 }
546 if (!fFound)
547 return VBoxServiceSyntax("Unknown option '%s'\n", argv[i]);
548 continue;
549 }
550#undef MATCHES
551 }
552
553 /* handle the string of short options. */
554 do
555 {
556 switch (*psz)
557 {
558 case 'i':
559 rc = VBoxServiceArgUInt32(argc, argv, psz + 1, &i,
560 &g_DefaultInterval, 1, (UINT32_MAX / 1000) - 1);
561 if (rc)
562 return rc;
563 psz = NULL;
564 break;
565
566 case 'f':
567 fDaemonize = false;
568 break;
569
570 case 'v':
571 g_cVerbosity++;
572 break;
573
574 case 'h':
575 case '?':
576 return VBoxServiceUsage();
577
578#ifdef RT_OS_WINDOWS
579 case 'r':
580 return VBoxServiceWinInstall();
581
582 case 'u':
583 return VBoxServiceWinUninstall();
584#endif
585
586 default:
587 {
588 bool fFound = false;
589 for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
590 {
591 rc = g_aServices[j].pDesc->pfnOption(&psz, argc, argv, &i);
592 fFound = rc == 0;
593 if (fFound)
594 break;
595 if (rc != -1)
596 return rc;
597 }
598 if (!fFound)
599 return VBoxServiceSyntax("Unknown option '%c' (%s)\n", *psz, argv[i]);
600 break;
601 }
602 }
603 } while (psz && *++psz);
604 }
605 /*
606 * Check that at least one service is enabled.
607 */
608 unsigned iMain = VBoxServiceGetStartedServices();
609 if (iMain == ~0U)
610 return VBoxServiceSyntax("At least one service must be enabled.\n");
611
612#ifndef RT_OS_WINDOWS
613 /*
614 * POSIX: No main service thread.
615 */
616 iMain = ~0U;
617#endif
618
619 VBoxServiceVerbose(0, "%s r%s started. Verbose level = %d\n",
620 RTBldCfgVersion(), RTBldCfgRevisionStr(), g_cVerbosity);
621
622 /*
623 * Daemonize if requested.
624 */
625 if (fDaemonize && !fDaemonized)
626 {
627#ifdef RT_OS_WINDOWS
628 /** @todo Should do something like VBoxSVC here, OR automatically re-register
629 * the service and start it. Involving VbglR3Daemonize isn't an option
630 * here.
631 *
632 * Also, the idea here, IIRC, was to map the sub service to windows
633 * services. The todo below is for mimicking windows services on
634 * non-windows systems. Not sure if this is doable or not, but in anycase
635 * this code can be moved into -win.
636 *
637 * You should return when StartServiceCtrlDispatcher, btw., not
638 * continue.
639 */
640 VBoxServiceVerbose(2, "Starting service dispatcher ...\n");
641 if (!StartServiceCtrlDispatcher(&g_aServiceTable[0]))
642 return VBoxServiceError("StartServiceCtrlDispatcher: %u. Please start %s with option -f (foreground)!",
643 GetLastError(), g_pszProgName);
644 /* Service now lives in the control dispatcher registered above. */
645#else
646 VBoxServiceVerbose(1, "Daemonizing...\n");
647 rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */);
648 if (RT_FAILURE(rc))
649 return VBoxServiceError("Daemon failed: %Rrc\n", rc);
650 /* in-child */
651#endif
652 }
653#ifdef RT_OS_WINDOWS
654 else
655#endif
656 {
657 /*
658 * Windows: We're running the service as a console application now. Start the
659 * services, enter the main thread's run loop and stop them again
660 * when it returns.
661 *
662 * POSIX: This is used for both daemons and console runs. Start all services
663 * and return immediately.
664 */
665 rc = VBoxServiceStartServices(iMain);
666#ifndef RT_OS_WINDOWS
667 if (RT_SUCCESS(rc))
668 VBoxServiceWaitSignal();
669#endif
670 VBoxServiceStopServices();
671 }
672
673#ifdef RT_OS_WINDOWS
674 /*
675 * Release instance mutex if we got it.
676 */
677 if (hMutexAppRunning != NULL)
678 {
679 ::CloseHandle(hMutexAppRunning);
680 hMutexAppRunning = NULL;
681 }
682#endif
683
684 VBoxServiceVerbose(0, "Ended.\n");
685 return RT_SUCCESS(rc) ? 0 : 1;
686}
687
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette