OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Build up the argv vector. This is done in PreFork() instead of | 55 // Build up the argv vector. This is done in PreFork() instead of |
56 // MultiprocessChild() because although the result is only needed in the child | 56 // MultiprocessChild() because although the result is only needed in the child |
57 // process, building it is a hazardous operation in that process. | 57 // process, building it is a hazardous operation in that process. |
58 ASSERT_TRUE(argv_.empty()); | 58 ASSERT_TRUE(argv_.empty()); |
59 | 59 |
60 argv_.push_back(command_.c_str()); | 60 argv_.push_back(command_.c_str()); |
61 for (const std::string& argument : arguments_) { | 61 for (const std::string& argument : arguments_) { |
62 argv_.push_back(argument.c_str()); | 62 argv_.push_back(argument.c_str()); |
63 } | 63 } |
64 argv_.push_back(NULL); | 64 argv_.push_back(nullptr); |
65 } | 65 } |
66 | 66 |
67 void MultiprocessExec::MultiprocessChild() { | 67 void MultiprocessExec::MultiprocessChild() { |
68 // Make sure that stdin, stdout, and stderr are FDs 0, 1, and 2, respectively. | 68 // Make sure that stdin, stdout, and stderr are FDs 0, 1, and 2, respectively. |
69 // All FDs above this will be closed. | 69 // All FDs above this will be closed. |
70 static_assert(STDIN_FILENO == 0, "stdin must be fd 0"); | 70 static_assert(STDIN_FILENO == 0, "stdin must be fd 0"); |
71 static_assert(STDOUT_FILENO == 1, "stdout must be fd 1"); | 71 static_assert(STDOUT_FILENO == 1, "stdout must be fd 1"); |
72 static_assert(STDERR_FILENO == 2, "stderr must be fd 2"); | 72 static_assert(STDERR_FILENO == 2, "stderr must be fd 2"); |
73 | 73 |
74 // Move the read pipe to stdin. | 74 // Move the read pipe to stdin. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 IGNORE_EINTR(close(STDOUT_FILENO)); | 131 IGNORE_EINTR(close(STDOUT_FILENO)); |
132 HANDLE_EINTR(dup2(dup_orig_stdout_fd, STDOUT_FILENO)); | 132 HANDLE_EINTR(dup2(dup_orig_stdout_fd, STDOUT_FILENO)); |
133 IGNORE_EINTR(close(dup_orig_stdout_fd)); | 133 IGNORE_EINTR(close(dup_orig_stdout_fd)); |
134 | 134 |
135 forbid_return.Disarm(); | 135 forbid_return.Disarm(); |
136 FAIL() << ErrnoMessage("execv") << ": " << argv_[0]; | 136 FAIL() << ErrnoMessage("execv") << ": " << argv_[0]; |
137 } | 137 } |
138 | 138 |
139 } // namespace test | 139 } // namespace test |
140 } // namespace crashpad | 140 } // namespace crashpad |
OLD | NEW |