Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/process_singleton_posix.cc

Issue 1984263002: process_singleton_posix: Remove the singleton lock file is not a symlink Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 } 273 }
274 return true; 274 return true;
275 } 275 }
276 276
277 // Extract the hostname and pid from the lock symlink. 277 // Extract the hostname and pid from the lock symlink.
278 // Returns true if the lock existed. 278 // Returns true if the lock existed.
279 bool ParseLockPath(const base::FilePath& path, 279 bool ParseLockPath(const base::FilePath& path,
280 std::string* hostname, 280 std::string* hostname,
281 int* pid) { 281 int* pid) {
282 // The lock file should be a symlink, not a regular file or a directory.
283 if (base::PathExists(path) && !base::IsLink(path)) {
284 base::DeleteFile(path, true);
285 return false;
286 }
287
282 std::string real_path = ReadLink(path).value(); 288 std::string real_path = ReadLink(path).value();
283 if (real_path.empty()) 289 if (real_path.empty())
284 return false; 290 return false;
285 291
286 std::string::size_type pos = real_path.rfind(kLockDelimiter); 292 std::string::size_type pos = real_path.rfind(kLockDelimiter);
287 293
288 // If the path is not a symbolic link, or doesn't contain what we expect, 294 // If the path is not a symbolic link, or doesn't contain what we expect,
289 // bail. 295 // bail.
290 if (pos == std::string::npos) { 296 if (pos == std::string::npos) {
291 *hostname = ""; 297 *hostname = "";
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 } 1061 }
1056 1062
1057 void ProcessSingleton::KillProcess(int pid) { 1063 void ProcessSingleton::KillProcess(int pid) {
1058 // TODO(james.su@gmail.com): Is SIGKILL ok? 1064 // TODO(james.su@gmail.com): Is SIGKILL ok?
1059 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); 1065 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
1060 // ESRCH = No Such Process (can happen if the other process is already in 1066 // 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). 1067 // progress of shutting down and finishes before we try to kill it).
1062 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " 1068 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
1063 << base::safe_strerror(errno); 1069 << base::safe_strerror(errno);
1064 } 1070 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698