/src/mozilla-central/ipc/glue/ProcessChild.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "nsDebug.h" |
8 | | |
9 | | #ifdef XP_WIN |
10 | | #include <stdlib.h> // for _exit() |
11 | | #else |
12 | | #include <unistd.h> // for _exit() |
13 | | #endif |
14 | | |
15 | | #include "mozilla/ipc/IOThreadChild.h" |
16 | | #include "mozilla/ipc/ProcessChild.h" |
17 | | |
18 | | namespace mozilla { |
19 | | namespace ipc { |
20 | | |
21 | | ProcessChild* ProcessChild::gProcessChild; |
22 | | |
23 | | ProcessChild::ProcessChild(ProcessId aParentPid) |
24 | | : ChildProcess(new IOThreadChild()) |
25 | | , mUILoop(MessageLoop::current()) |
26 | | , mParentPid(aParentPid) |
27 | 0 | { |
28 | 0 | MOZ_ASSERT(mUILoop, "UILoop should be created by now"); |
29 | 0 | MOZ_ASSERT(!gProcessChild, "should only be one ProcessChild"); |
30 | 0 | gProcessChild = this; |
31 | 0 | } |
32 | | |
33 | | ProcessChild::~ProcessChild() |
34 | 0 | { |
35 | 0 | gProcessChild = nullptr; |
36 | 0 | } |
37 | | |
38 | | /* static */ void |
39 | | ProcessChild::QuickExit() |
40 | 0 | { |
41 | | #ifdef XP_WIN |
42 | | // In bug 1254829, the destructor got called when dll got detached on windows, |
43 | | // switch to TerminateProcess to bypass dll detach handler during the process |
44 | | // termination. |
45 | | TerminateProcess(GetCurrentProcess(), 0); |
46 | | #else |
47 | | _exit(0); |
48 | 0 | #endif |
49 | 0 | } |
50 | | |
51 | | } // namespace ipc |
52 | | } // namespace mozilla |