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 <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <pthread.h> | 7 #include <pthread.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // once all of our childs are dead. Since we're init we need to reap childs | 312 // once all of our childs are dead. Since we're init we need to reap childs |
313 // as they come. | 313 // as they come. |
314 struct sigaction action; | 314 struct sigaction action; |
315 memset(&action, 0, sizeof(action)); | 315 memset(&action, 0, sizeof(action)); |
316 action.sa_handler = &SIGCHLDHandler; | 316 action.sa_handler = &SIGCHLDHandler; |
317 CHECK(sigaction(SIGCHLD, &action, NULL) == 0); | 317 CHECK(sigaction(SIGCHLD, &action, NULL) == 0); |
318 | 318 |
319 (void) HANDLE_EINTR(close(sync_fds[0])); | 319 (void) HANDLE_EINTR(close(sync_fds[0])); |
320 shutdown(sync_fds[1], SHUT_RD); | 320 shutdown(sync_fds[1], SHUT_RD); |
321 // This "magic" socket must only appear in one process. | 321 // This "magic" socket must only appear in one process. |
322 (void) HANDLE_EINTR(close(content::kZygoteIdFd)); | 322 (void) HANDLE_EINTR(close(kZygoteIdFd)); |
323 // Tell the child to continue | 323 // Tell the child to continue |
324 CHECK(HANDLE_EINTR(send(sync_fds[1], "C", 1, MSG_NOSIGNAL)) == 1); | 324 CHECK(HANDLE_EINTR(send(sync_fds[1], "C", 1, MSG_NOSIGNAL)) == 1); |
325 (void) HANDLE_EINTR(close(sync_fds[1])); | 325 (void) HANDLE_EINTR(close(sync_fds[1])); |
326 | 326 |
327 for (;;) { | 327 for (;;) { |
328 // Loop until we have reaped our one natural child | 328 // Loop until we have reaped our one natural child |
329 siginfo_t reaped_child_info; | 329 siginfo_t reaped_child_info; |
330 int wait_ret = | 330 int wait_ret = |
331 HANDLE_EINTR(waitid(P_ALL, 0, &reaped_child_info, WEXITED)); | 331 HANDLE_EINTR(waitid(P_ALL, 0, &reaped_child_info, WEXITED)); |
332 if (wait_ret) | 332 if (wait_ret) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 489 } |
490 | 490 |
491 int sandbox_flags = linux_sandbox->GetStatus(); | 491 int sandbox_flags = linux_sandbox->GetStatus(); |
492 | 492 |
493 Zygote zygote(sandbox_flags, forkdelegate); | 493 Zygote zygote(sandbox_flags, forkdelegate); |
494 // This function call can return multiple times, once per fork(). | 494 // This function call can return multiple times, once per fork(). |
495 return zygote.ProcessRequests(); | 495 return zygote.ProcessRequests(); |
496 } | 496 } |
497 | 497 |
498 } // namespace content | 498 } // namespace content |
OLD | NEW |