OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
9 #include "base/process/launch.h" | 9 #include "base/process/launch.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (pipe(pipe_fd) < 0) | 158 if (pipe(pipe_fd) < 0) |
159 return false; | 159 return false; |
160 | 160 |
161 switch (pid = fork()) { | 161 switch (pid = fork()) { |
162 case -1: // error | 162 case -1: // error |
163 close(pipe_fd[0]); | 163 close(pipe_fd[0]); |
164 close(pipe_fd[1]); | 164 close(pipe_fd[1]); |
165 return false; | 165 return false; |
166 case 0: // child | 166 case 0: // child |
167 { | 167 { |
168 #if defined(OS_MACOSX) | |
169 base::RestoreDefaultExceptionHandler(); | |
170 #endif | |
171 // DANGER: no calls to malloc are allowed from now on: | 168 // DANGER: no calls to malloc are allowed from now on: |
172 // http://crbug.com/36678 | 169 // http://crbug.com/36678 |
173 | 170 |
174 // Obscure fork() rule: in the child, if you don't end up doing exec*(), | 171 // Obscure fork() rule: in the child, if you don't end up doing exec*(), |
175 // you call _exit() instead of exit(). This is because _exit() does not | 172 // you call _exit() instead of exit(). This is because _exit() does not |
176 // call any previously-registered (in the parent) exit handlers, which | 173 // call any previously-registered (in the parent) exit handlers, which |
177 // might do things like block waiting for threads that don't even exist | 174 // might do things like block waiting for threads that don't even exist |
178 // in the child. | 175 // in the child. |
179 int dev_null = open("/dev/null", O_WRONLY); | 176 int dev_null = open("/dev/null", O_WRONLY); |
180 if (dev_null < 0) | 177 if (dev_null < 0) |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 msg += "."; | 380 msg += "."; |
384 *err = Err(function->function(), "Script returned non-zero exit code.", | 381 *err = Err(function->function(), "Script returned non-zero exit code.", |
385 msg); | 382 msg); |
386 return Value(); | 383 return Value(); |
387 } | 384 } |
388 | 385 |
389 return ConvertInputToValue(output, function, args[2], err); | 386 return ConvertInputToValue(output, function, args[2], err); |
390 } | 387 } |
391 | 388 |
392 } // namespace functions | 389 } // namespace functions |
OLD | NEW |