| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // On Linux, when the user tries to launch a second copy of chrome, we check | 5 // On Linux, when the user tries to launch a second copy of chrome, we check |
| 6 // for a socket in the user's profile directory. If the socket file is open we | 6 // for a socket in the user's profile directory. If the socket file is open we |
| 7 // send a message to the first chrome browser process with the current | 7 // send a message to the first chrome browser process with the current |
| 8 // directory and second process command line flags. The second process then | 8 // directory and second process command line flags. The second process then |
| 9 // exits. | 9 // exits. |
| 10 // | 10 // |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include <sys/socket.h> | 45 #include <sys/socket.h> |
| 46 #include <sys/stat.h> | 46 #include <sys/stat.h> |
| 47 #include <sys/types.h> | 47 #include <sys/types.h> |
| 48 #include <sys/un.h> | 48 #include <sys/un.h> |
| 49 #include <unistd.h> | 49 #include <unistd.h> |
| 50 | 50 |
| 51 #include <cstring> | 51 #include <cstring> |
| 52 #include <set> | 52 #include <set> |
| 53 #include <string> | 53 #include <string> |
| 54 | 54 |
| 55 #include <stddef.h> |
| 56 |
| 55 #include "base/base_paths.h" | 57 #include "base/base_paths.h" |
| 56 #include "base/basictypes.h" | |
| 57 #include "base/bind.h" | 58 #include "base/bind.h" |
| 58 #include "base/command_line.h" | 59 #include "base/command_line.h" |
| 59 #include "base/files/file_path.h" | 60 #include "base/files/file_path.h" |
| 60 #include "base/files/file_util.h" | 61 #include "base/files/file_util.h" |
| 61 #include "base/location.h" | 62 #include "base/location.h" |
| 62 #include "base/logging.h" | 63 #include "base/logging.h" |
| 64 #include "base/macros.h" |
| 63 #include "base/message_loop/message_loop.h" | 65 #include "base/message_loop/message_loop.h" |
| 64 #include "base/path_service.h" | 66 #include "base/path_service.h" |
| 65 #include "base/posix/eintr_wrapper.h" | 67 #include "base/posix/eintr_wrapper.h" |
| 66 #include "base/posix/safe_strerror.h" | 68 #include "base/posix/safe_strerror.h" |
| 67 #include "base/rand_util.h" | 69 #include "base/rand_util.h" |
| 68 #include "base/sequenced_task_runner_helpers.h" | 70 #include "base/sequenced_task_runner_helpers.h" |
| 69 #include "base/single_thread_task_runner.h" | 71 #include "base/single_thread_task_runner.h" |
| 70 #include "base/stl_util.h" | 72 #include "base/stl_util.h" |
| 71 #include "base/strings/string_number_conversions.h" | 73 #include "base/strings/string_number_conversions.h" |
| 72 #include "base/strings/string_split.h" | 74 #include "base/strings/string_split.h" |
| 73 #include "base/strings/string_util.h" | 75 #include "base/strings/string_util.h" |
| 74 #include "base/strings/stringprintf.h" | 76 #include "base/strings/stringprintf.h" |
| 75 #include "base/strings/sys_string_conversions.h" | 77 #include "base/strings/sys_string_conversions.h" |
| 76 #include "base/strings/utf_string_conversions.h" | 78 #include "base/strings/utf_string_conversions.h" |
| 77 #include "base/threading/platform_thread.h" | 79 #include "base/threading/platform_thread.h" |
| 78 #include "base/time/time.h" | 80 #include "base/time/time.h" |
| 79 #include "base/timer/timer.h" | 81 #include "base/timer/timer.h" |
| 82 #include "build/build_config.h" |
| 80 #include "chrome/common/chrome_constants.h" | 83 #include "chrome/common/chrome_constants.h" |
| 81 #include "chrome/grit/chromium_strings.h" | 84 #include "chrome/grit/chromium_strings.h" |
| 82 #include "chrome/grit/generated_resources.h" | 85 #include "chrome/grit/generated_resources.h" |
| 83 #include "content/public/browser/browser_thread.h" | 86 #include "content/public/browser/browser_thread.h" |
| 84 #include "net/base/net_util.h" | 87 #include "net/base/net_util.h" |
| 85 #include "ui/base/l10n/l10n_util.h" | 88 #include "ui/base/l10n/l10n_util.h" |
| 86 | 89 |
| 87 #if defined(OS_LINUX) | 90 #if defined(OS_LINUX) |
| 88 #include "chrome/browser/ui/process_singleton_dialog_linux.h" | 91 #include "chrome/browser/ui/process_singleton_dialog_linux.h" |
| 89 #endif | 92 #endif |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 } | 1055 } |
| 1053 | 1056 |
| 1054 void ProcessSingleton::KillProcess(int pid) { | 1057 void ProcessSingleton::KillProcess(int pid) { |
| 1055 // TODO(james.su@gmail.com): Is SIGKILL ok? | 1058 // TODO(james.su@gmail.com): Is SIGKILL ok? |
| 1056 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); | 1059 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); |
| 1057 // ESRCH = No Such Process (can happen if the other process is already in | 1060 // ESRCH = No Such Process (can happen if the other process is already in |
| 1058 // progress of shutting down and finishes before we try to kill it). | 1061 // progress of shutting down and finishes before we try to kill it). |
| 1059 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " | 1062 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " |
| 1060 << base::safe_strerror(errno); | 1063 << base::safe_strerror(errno); |
| 1061 } | 1064 } |
| OLD | NEW |