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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 } | 1001 } |
1002 | 1002 |
1003 if (listen(sock, 5) < 0) | 1003 if (listen(sock, 5) < 0) |
1004 NOTREACHED() << "listen failed: " << base::safe_strerror(errno); | 1004 NOTREACHED() << "listen failed: " << base::safe_strerror(errno); |
1005 | 1005 |
1006 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); | 1006 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); |
1007 BrowserThread::PostTask( | 1007 BrowserThread::PostTask( |
1008 BrowserThread::IO, | 1008 BrowserThread::IO, |
1009 FROM_HERE, | 1009 FROM_HERE, |
1010 base::Bind(&ProcessSingleton::LinuxWatcher::StartListening, | 1010 base::Bind(&ProcessSingleton::LinuxWatcher::StartListening, |
1011 watcher_.get(), | 1011 watcher_, |
1012 sock)); | 1012 sock)); |
1013 | 1013 |
1014 return true; | 1014 return true; |
1015 } | 1015 } |
1016 | 1016 |
1017 void ProcessSingleton::Cleanup() { | 1017 void ProcessSingleton::Cleanup() { |
1018 UnlinkPath(socket_path_); | 1018 UnlinkPath(socket_path_); |
1019 UnlinkPath(cookie_path_); | 1019 UnlinkPath(cookie_path_); |
1020 UnlinkPath(lock_path_); | 1020 UnlinkPath(lock_path_); |
1021 } | 1021 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 } | 1055 } |
1056 | 1056 |
1057 void ProcessSingleton::KillProcess(int pid) { | 1057 void ProcessSingleton::KillProcess(int pid) { |
1058 // TODO(james.su@gmail.com): Is SIGKILL ok? | 1058 // TODO(james.su@gmail.com): Is SIGKILL ok? |
1059 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); | 1059 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); |
1060 // 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 |
1061 // 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). |
1062 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " | 1062 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " |
1063 << base::safe_strerror(errno); | 1063 << base::safe_strerror(errno); |
1064 } | 1064 } |
OLD | NEW |