Changeset 52577 in vbox
- Timestamp:
- Sep 3, 2014 9:59:36 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
r52562 r52577 72 72 system(pszCommand); 73 73 } 74 exit(1);74 _exit(1); 75 75 } 76 76 … … 84 84 int rc = RTCritSectEnter(&g_critSect); 85 85 if (RT_FAILURE(rc)) 86 { 87 LogRel(("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc)); 88 abort(); 89 } 86 VBClFatalError(("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc)); 90 87 if (g_pService) 91 88 (*g_pService)->cleanup(g_pService); … … 99 96 * A standard signal handler which cleans up and exits. 100 97 */ 101 void vboxClientSignalHandler(int cSignal)98 static void vboxClientSignalHandler(int cSignal) 102 99 { 103 100 LogRel(("VBoxClient: terminated with signal %d\n", cSignal)); … … 110 107 * Xlib error handler for certain errors that we can't avoid. 111 108 */ 112 int vboxClientXLibErrorHandler(Display *pDisplay, XErrorEvent *pError)109 static int vboxClientXLibErrorHandler(Display *pDisplay, XErrorEvent *pError) 113 110 { 114 111 char errorText[1024]; … … 134 131 * cleans up and exits. 135 132 */ 136 void vboxClientSetSignalHandlers(void)133 static void vboxClientSetSignalHandlers(void) 137 134 { 138 135 struct sigaction sigAction; … … 361 358 * object should probably never be used from multiple threads anyway. */ 362 359 if (!XInitThreads()) 363 return 1;360 VBClFatalError(("Failed to initialize X11 threads\n")); 364 361 /* Get our file name for error output. */ 365 362 pcszFileName = RTPathFilename(argv[0]); … … 369 366 rc = VbglR3InitUser(); 370 367 if (RT_FAILURE(rc)) 371 { 372 RTPrintf("%s: failed to connect to the VirtualBox kernel service, rc=%Rrc\n", 373 pcszFileName, rc); 374 return 1; 375 } 368 VBClFatalError(("%s: failed to connect to the VirtualBox kernel service, rc=%Rrc\n", 369 pcszFileName, rc)); 376 370 377 371 /* Parse our option(s) */ … … 444 438 } 445 439 446 do { 447 pcszStage = "Initialising critical section"; 448 rc = RTCritSectInit(&g_critSect); 449 if (RT_FAILURE(rc)) 450 break; 451 pcszStage = "Getting home directory for pid-file"; 452 rc = RTPathUserHome(g_szPidFile, sizeof(g_szPidFile)); 453 if (RT_FAILURE(rc)) 454 break; 455 pcszStage = "Creating pid-file path"; 456 rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile), 457 (*g_pService)->getPidFilePath()); 458 if (RT_FAILURE(rc)) 459 break; 460 pcszStage = "Daemonising"; 461 if (fDaemonise) 462 rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */); 463 if (RT_FAILURE(rc)) 464 break; 465 pcszStage = "Creating pid-file"; 466 if (g_szPidFile[0]) 467 rc = VbglR3PidFile(g_szPidFile, &g_hPidFile); 468 if (RT_FAILURE(rc)) 469 break; 470 /* Set signal handlers to clean up on exit. */ 471 vboxClientSetSignalHandlers(); 472 /* Set an X11 error handler, so that we don't die when we get unavoidable 473 * errors. */ 474 XSetErrorHandler(vboxClientXLibErrorHandler); 475 /* Set an X11 I/O error handler, so that we can shutdown properly on 476 * fatal errors. */ 477 XSetIOErrorHandler(vboxClientXLibIOErrorHandler); 478 pcszStage = "Initialising service"; 479 rc = (*g_pService)->init(g_pService); 480 } while (0); 481 if (RT_FAILURE(rc)) 482 { 483 LogRelFunc(("VBoxClient: failed at stage: \"%s\" rc: %Rrc\n", 484 pcszStage, rc)); 485 VbglR3Term(); 486 return 1; 487 } 488 440 rc = RTCritSectInit(&g_critSect); 441 if (RT_FAILURE(rc)) 442 VBClFatalError(("Initialising critical section: %Rrc\n", rc)); 443 if (RT_FAILURE(rc)) 444 VBClFatalError(("Initialising critical section: %Rrc\n", rc)); 445 rc = RTPathUserHome(g_szPidFile, sizeof(g_szPidFile)); 446 if (RT_FAILURE(rc)) 447 VBClFatalError(("Getting home directory for pid-file: %Rrc\n", rc)); 448 rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile), 449 (*g_pService)->getPidFilePath()); 450 if (RT_FAILURE(rc)) 451 VBClFatalError(("Creating pid-file path: %Rrc\n", rc)); 452 if (fDaemonise) 453 rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */); 454 if (RT_FAILURE(rc)) 455 VBClFatalError(("Daemonizing: %Rrc\n", rc)); 456 if (g_szPidFile[0]) 457 rc = VbglR3PidFile(g_szPidFile, &g_hPidFile); 458 if (RT_FAILURE(rc)) 459 VBClFatalError(("Creating pid-file: %Rrc\n", rc)); 460 /* Set signal handlers to clean up on exit. */ 461 vboxClientSetSignalHandlers(); 462 /* Set an X11 error handler, so that we don't die when we get unavoidable 463 * errors. */ 464 XSetErrorHandler(vboxClientXLibErrorHandler); 465 /* Set an X11 I/O error handler, so that we can shutdown properly on 466 * fatal errors. */ 467 XSetIOErrorHandler(vboxClientXLibIOErrorHandler); 468 rc = (*g_pService)->init(g_pService); 469 if (RT_FAILURE(rc)) 470 VBClFatalError(("Initialising service: %Rrc\n", rc)); 489 471 rc = startMonitorThread(); 490 472 if (RT_FAILURE(rc)) 491 LogRel(("Failed to start the monitor thread (%Rrc). Exiting.\n", 492 rc)); 493 else 494 (*g_pService)->run(g_pService, fDaemonise); /* Should never return. */ 473 VBClFatalError(("Starting monitor thread: %Rrc\n", rc)); 474 (*g_pService)->run(g_pService, fDaemonise); /* Should never return. */ 495 475 VBClCleanUp(); 496 476 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.