| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/zygote/zygote_linux.h" | 5 #include "content/zygote/zygote_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 const base::ProcessHandle child = child_info.internal_pid; | 216 const base::ProcessHandle child = child_info.internal_pid; |
| 217 if (child_info.started_from_helper) { | 217 if (child_info.started_from_helper) { |
| 218 // Let the helper handle the request. | 218 // Let the helper handle the request. |
| 219 DCHECK(helper_); | 219 DCHECK(helper_); |
| 220 if (!helper_->GetTerminationStatus(child, known_dead, status, exit_code)) { | 220 if (!helper_->GetTerminationStatus(child, known_dead, status, exit_code)) { |
| 221 return false; | 221 return false; |
| 222 } | 222 } |
| 223 } else { | 223 } else { |
| 224 // Handle the request directly. | 224 // Handle the request directly. |
| 225 if (known_dead) { | 225 if (known_dead) { |
| 226 // If we know that the process is already dead and the kernel is cleaning | 226 *status = base::GetKnownDeadTerminationStatus(child, exit_code); |
| 227 // it up, we do want to wait until it becomes a zombie and not risk | |
| 228 // returning eroneously that it is still running. However, we do not | |
| 229 // want to risk a bug where we're told a process is dead when it's not. | |
| 230 // By sending SIGKILL, we make sure that WaitForTerminationStatus will | |
| 231 // return quickly even in this case. | |
| 232 if (kill(child, SIGKILL)) { | |
| 233 PLOG(ERROR) << "kill (" << child << ")"; | |
| 234 } | |
| 235 *status = base::WaitForTerminationStatus(child, exit_code); | |
| 236 } else { | 227 } else { |
| 237 // We don't know if the process is dying, so get its status but don't | 228 // We don't know if the process is dying, so get its status but don't |
| 238 // wait. | 229 // wait. |
| 239 *status = base::GetTerminationStatus(child, exit_code); | 230 *status = base::GetTerminationStatus(child, exit_code); |
| 240 } | 231 } |
| 241 } | 232 } |
| 242 // Successfully got a status for |real_pid|. | 233 // Successfully got a status for |real_pid|. |
| 243 if (*status != base::TERMINATION_STATUS_STILL_RUNNING) { | 234 if (*status != base::TERMINATION_STATUS_STILL_RUNNING) { |
| 244 // Time to forget about this process. | 235 // Time to forget about this process. |
| 245 process_info_map_.erase(real_pid); | 236 process_info_map_.erase(real_pid); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 PickleIterator iter) { | 529 PickleIterator iter) { |
| 539 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != | 530 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != |
| 540 sizeof(sandbox_flags_)) { | 531 sizeof(sandbox_flags_)) { |
| 541 PLOG(ERROR) << "write"; | 532 PLOG(ERROR) << "write"; |
| 542 } | 533 } |
| 543 | 534 |
| 544 return false; | 535 return false; |
| 545 } | 536 } |
| 546 | 537 |
| 547 } // namespace content | 538 } // namespace content |
| OLD | NEW |