~ubuntu-branches/ubuntu/natty/virtualbox-ose/natty-updates

« back to all changes in this revision

Viewing changes to src/VBox/Additions/x11/VBoxClient/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-10-15 02:12:28 UTC
  • mfrom: (0.3.10 upstream) (0.4.19 sid)
  • Revision ID: james.westby@ubuntu.com-20101015021228-5e6vbxgtes8mg189
Tags: 3.2.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - VirtualBox should go in Accessories, not in System tools.
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add ubuntu-01-fix-build-gcc45.patch to fix FTBFS due to uninitalized
  variables. Thanks to Lubomir Rintel <lkundrak@v3.sk> for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include <X11/Xlib.h>
28
28
 
 
29
#include <iprt/critsect.h>
29
30
#include <iprt/env.h>
30
31
#include <iprt/initterm.h>
31
32
#include <iprt/path.h>
50
51
/** The file handle of our pidfile.  It is global for the benefit of the
51
52
 * cleanup routine. */
52
53
static RTFILE g_hPidFile;
 
54
/** Global critical section used to protect the clean-up routine, which can be
 
55
 * called from different threads.
 
56
 */
 
57
RTCRITSECT g_critSect;
53
58
 
54
59
/** Clean up if we get a signal or something.  This is extern so that we
55
60
 * can call it from other compilation units. */
56
61
void VBoxClient::CleanUp()
57
62
{
 
63
    /* We never release this, as we end up with a call to exit(3) which is not
 
64
     * async-safe.  Until we fix this application properly, we should be sure
 
65
     * never to exit from anywhere except from this method. */
 
66
    int rc = RTCritSectEnter(&g_critSect);
 
67
    if (RT_FAILURE(rc))
 
68
    {
 
69
        RTPrintf("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc);
 
70
        abort();
 
71
    }
58
72
    if (g_pService)
59
 
    {
60
73
        g_pService->cleanup();
61
 
        delete g_pService;
62
 
    }
63
74
    if (g_szPidFile[0] && g_hPidFile)
64
75
        VbglR3ClosePidFile(g_szPidFile, g_hPidFile);
65
76
    VbglR3Term();
115
126
    sigaction(SIGHUP, &sigAction, NULL);
116
127
    sigaction(SIGINT, &sigAction, NULL);
117
128
    sigaction(SIGQUIT, &sigAction, NULL);
118
 
    sigaction(SIGABRT, &sigAction, NULL);
119
129
    sigaction(SIGPIPE, &sigAction, NULL);
120
130
    sigaction(SIGALRM, &sigAction, NULL);
121
131
    sigaction(SIGTERM, &sigAction, NULL);
148
158
 */
149
159
int main(int argc, char *argv[])
150
160
{
151
 
    int rcClipboard, rc = VINF_SUCCESS;
 
161
    int rcClipboard, rc;
152
162
    const char *pszFileName = RTPathFilename(argv[0]);
153
163
    bool fDaemonise = true;
154
164
    /* Have any fatal errors occurred yet? */
160
170
        pszFileName = "VBoxClient";
161
171
 
162
172
    /* Initialise our runtime before all else. */
163
 
    RTR3Init();
 
173
    rc = RTR3Init();
 
174
    if (RT_FAILURE(rc))
 
175
    {
 
176
        /* Of course, this should never happen. */
 
177
        RTPrintf("%s: Failed to initialise the run-time library, rc=%Rrc\n", pszFileName, rc);
 
178
        exit(1);
 
179
    }
 
180
 
 
181
    /* Initialise our global clean-up critical section */
 
182
    rc = RTCritSectInit(&g_critSect);
 
183
    if (RT_FAILURE(rc))
 
184
    {
 
185
        /* Of course, this should never happen. */
 
186
        RTPrintf("%s: Failed to initialise the global critical section, rc=%Rrc\n", pszFileName, rc);
 
187
        exit(1);
 
188
    }
164
189
 
165
190
    /* Parse our option(s) */
166
191
    /** @todo Use RTGetOpt() if the arguments become more complex. */