| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/mac/relauncher.h" | 5 #include "chrome/browser/mac/relauncher.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #include <AvailabilityMacros.h> | 8 #include <AvailabilityMacros.h> |
| 9 #include <crt_externs.h> | 9 #include <crt_externs.h> |
| 10 #include <dlfcn.h> | 10 #include <dlfcn.h> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // forked off. The relauncher process will only use pipe_write_fd as the | 132 // forked off. The relauncher process will only use pipe_write_fd as the |
| 133 // write side of the pipe. In that process, the read side will be closed by | 133 // write side of the pipe. In that process, the read side will be closed by |
| 134 // base::LaunchApp because it won't be present in fd_map, and the write side | 134 // base::LaunchApp because it won't be present in fd_map, and the write side |
| 135 // will be remapped to kRelauncherSyncFD by fd_map. | 135 // will be remapped to kRelauncherSyncFD by fd_map. |
| 136 base::ScopedFD pipe_read_fd(pipe_fds[0]); | 136 base::ScopedFD pipe_read_fd(pipe_fds[0]); |
| 137 base::ScopedFD pipe_write_fd(pipe_fds[1]); | 137 base::ScopedFD pipe_write_fd(pipe_fds[1]); |
| 138 | 138 |
| 139 // Make sure kRelauncherSyncFD is a safe value. base::LaunchProcess will | 139 // Make sure kRelauncherSyncFD is a safe value. base::LaunchProcess will |
| 140 // preserve these three FDs in forked processes, so kRelauncherSyncFD should | 140 // preserve these three FDs in forked processes, so kRelauncherSyncFD should |
| 141 // not conflict with them. | 141 // not conflict with them. |
| 142 COMPILE_ASSERT(kRelauncherSyncFD != STDIN_FILENO && | 142 static_assert(kRelauncherSyncFD != STDIN_FILENO && |
| 143 kRelauncherSyncFD != STDOUT_FILENO && | 143 kRelauncherSyncFD != STDOUT_FILENO && |
| 144 kRelauncherSyncFD != STDERR_FILENO, | 144 kRelauncherSyncFD != STDERR_FILENO, |
| 145 kRelauncherSyncFD_must_not_conflict_with_stdio_fds); | 145 "kRelauncherSyncFD must not conflict with stdio fds"); |
| 146 | 146 |
| 147 base::FileHandleMappingVector fd_map; | 147 base::FileHandleMappingVector fd_map; |
| 148 fd_map.push_back(std::make_pair(pipe_write_fd.get(), kRelauncherSyncFD)); | 148 fd_map.push_back(std::make_pair(pipe_write_fd.get(), kRelauncherSyncFD)); |
| 149 | 149 |
| 150 base::LaunchOptions options; | 150 base::LaunchOptions options; |
| 151 options.fds_to_remap = &fd_map; | 151 options.fds_to_remap = &fd_map; |
| 152 if (!base::LaunchProcess(relaunch_args, options, NULL)) { | 152 if (!base::LaunchProcess(relaunch_args, options, NULL)) { |
| 153 LOG(ERROR) << "base::LaunchProcess failed"; | 153 LOG(ERROR) << "base::LaunchProcess failed"; |
| 154 return false; | 154 return false; |
| 155 } | 155 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 if (!dmg_bsd_device_name.empty()) { | 370 if (!dmg_bsd_device_name.empty()) { |
| 371 EjectAndTrashDiskImage(dmg_bsd_device_name); | 371 EjectAndTrashDiskImage(dmg_bsd_device_name); |
| 372 } | 372 } |
| 373 | 373 |
| 374 return 0; | 374 return 0; |
| 375 } | 375 } |
| 376 | 376 |
| 377 } // namespace internal | 377 } // namespace internal |
| 378 | 378 |
| 379 } // namespace mac_relauncher | 379 } // namespace mac_relauncher |
| OLD | NEW |