OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "native_client/src/include/nacl_string.h" | 12 #include "native_client/src/include/nacl_string.h" |
13 #include "native_client/src/include/portability.h" | 13 #include "native_client/src/include/portability.h" |
14 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" | 14 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" |
15 #include "native_client/src/trusted/desc/nacl_desc_base.h" | 15 #include "native_client/src/trusted/desc/nacl_desc_base.h" |
16 | 16 |
17 // Use a predefined symbol to get a handle to the current module. | 17 // Use a predefined symbol to get a handle to the current module. |
18 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 18 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
19 // @IGNORE_LINES_FOR_CODE_HYGIENE[1] | 19 // @IGNORE_LINES_FOR_CODE_HYGIENE[1] |
20 extern "C" IMAGE_DOS_HEADER __ImageBase; | 20 extern "C" IMAGE_DOS_HEADER __ImageBase; |
21 | 21 |
22 using std::vector; | 22 using std::vector; |
23 | 23 |
24 namespace nacl { | 24 namespace nacl { |
25 | 25 |
26 SelLdrLauncher::~SelLdrLauncher() { | 26 SelLdrLauncher::~SelLdrLauncher() { |
27 CloseHandlesAfterLaunch(); | 27 CloseHandlesAfterLaunch(); |
28 if (kInvalidHandle != child_process_) { | 28 if (kInvalidHandle != child_process_) { |
| 29 // Ensure child process (service runtime) is kaput. NB: we might |
| 30 // close the command channel (or use the hard_shutdown RPC) rather |
| 31 // than killing the process to allow the service runtime to do |
| 32 // clean up, but the plugin should be responsible for that and we |
| 33 // shouldn't introduce any timeout wait in a dtor. Currently, |
| 34 // ServiceRuntime::Shutdown kills the subprocess before closing |
| 35 // the command channel, so we aren't providing the opportunity for |
| 36 // a more graceful shutdown. |
| 37 KillChildProcess(); |
29 CloseHandle(child_process_); | 38 CloseHandle(child_process_); |
30 } | 39 } |
31 if (kInvalidHandle != channel_) { | 40 if (kInvalidHandle != channel_) { |
32 Close(channel_); | 41 Close(channel_); |
33 } | 42 } |
34 } | 43 } |
35 | 44 |
36 nacl::string SelLdrLauncher::GetSelLdrPathName() { | 45 nacl::string SelLdrLauncher::GetSelLdrPathName() { |
37 char buffer[FILENAME_MAX]; | 46 char buffer[FILENAME_MAX]; |
38 // Currently only the Chrome build uses the gyp-generated binaries, and | 47 // Currently only the Chrome build uses the gyp-generated binaries, and |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // NOTE: casting down to DWORD is safe the integer will become smaller | 149 // NOTE: casting down to DWORD is safe the integer will become smaller |
141 // at worst | 150 // at worst |
142 GetModuleFileNameA(this_module, buffer, static_cast<DWORD>(len)); | 151 GetModuleFileNameA(this_module, buffer, static_cast<DWORD>(len)); |
143 char* path_end = strrchr(buffer, '\\'); | 152 char* path_end = strrchr(buffer, '\\'); |
144 if (NULL != path_end) { | 153 if (NULL != path_end) { |
145 *path_end = '\0'; | 154 *path_end = '\0'; |
146 } | 155 } |
147 } | 156 } |
148 | 157 |
149 } // namespace nacl | 158 } // namespace nacl |
OLD | NEW |