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 "base/process/launch.h" | 5 #include "base/process/launch.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <sched.h> | 10 #include <sched.h> |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 #if defined(OS_LINUX) | 516 #if defined(OS_LINUX) |
517 #ifndef PR_SET_NO_NEW_PRIVS | 517 #ifndef PR_SET_NO_NEW_PRIVS |
518 #define PR_SET_NO_NEW_PRIVS 38 | 518 #define PR_SET_NO_NEW_PRIVS 38 |
519 #endif | 519 #endif |
520 if (!options.allow_new_privs) { | 520 if (!options.allow_new_privs) { |
521 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { | 521 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { |
522 // Only log if the error is not EINVAL (i.e. not supported). | 522 // Only log if the error is not EINVAL (i.e. not supported). |
523 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); | 523 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); |
524 } | 524 } |
525 } | 525 } |
| 526 |
| 527 if (options.kill_on_parent_death) { |
| 528 if (prctl(PR_SET_PDEATHSIG, SIGKILL) != 0) { |
| 529 RAW_LOG(ERROR, "prctl(PR_SET_PDEATHSIG) failed"); |
| 530 _exit(127); |
| 531 } |
| 532 } |
526 #endif | 533 #endif |
527 | 534 |
528 if (current_directory != nullptr) { | 535 if (current_directory != nullptr) { |
529 RAW_CHECK(chdir(current_directory) == 0); | 536 RAW_CHECK(chdir(current_directory) == 0); |
530 } | 537 } |
531 | 538 |
532 if (options.pre_exec_delegate != nullptr) { | 539 if (options.pre_exec_delegate != nullptr) { |
533 options.pre_exec_delegate->RunAsyncSafe(); | 540 options.pre_exec_delegate->RunAsyncSafe(); |
534 } | 541 } |
535 | 542 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 jmp_buf env; | 776 jmp_buf env; |
770 if (setjmp(env) == 0) { | 777 if (setjmp(env) == 0) { |
771 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); | 778 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); |
772 } | 779 } |
773 | 780 |
774 return 0; | 781 return 0; |
775 } | 782 } |
776 #endif // defined(OS_LINUX) | 783 #endif // defined(OS_LINUX) |
777 | 784 |
778 } // namespace base | 785 } // namespace base |
OLD | NEW |