OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
7 | 7 |
8 #include "bin/process.h" | 8 #include "bin/process.h" |
9 | 9 |
| 10 #include <crt_externs.h> // NOLINT |
10 #include <errno.h> // NOLINT | 11 #include <errno.h> // NOLINT |
11 #include <fcntl.h> // NOLINT | 12 #include <fcntl.h> // NOLINT |
12 #include <poll.h> // NOLINT | 13 #include <poll.h> // NOLINT |
13 #include <signal.h> // NOLINT | 14 #include <signal.h> // NOLINT |
14 #include <stdio.h> // NOLINT | 15 #include <stdio.h> // NOLINT |
15 #include <stdlib.h> // NOLINT | 16 #include <stdlib.h> // NOLINT |
16 #include <string.h> // NOLINT | 17 #include <string.h> // NOLINT |
17 #include <unistd.h> // NOLINT | 18 #include <unistd.h> // NOLINT |
18 | 19 |
19 #include "bin/fdutils.h" | 20 #include "bin/fdutils.h" |
20 #include "bin/lockers.h" | 21 #include "bin/lockers.h" |
21 #include "bin/log.h" | 22 #include "bin/log.h" |
22 #include "bin/thread.h" | 23 #include "bin/thread.h" |
23 | 24 |
24 #include "platform/signal_blocker.h" | 25 #include "platform/signal_blocker.h" |
25 | 26 |
26 | 27 |
27 extern char **environ; | |
28 | |
29 | 28 |
30 namespace dart { | 29 namespace dart { |
31 namespace bin { | 30 namespace bin { |
32 | 31 |
33 // ProcessInfo is used to map a process id to the file descriptor for | 32 // ProcessInfo is used to map a process id to the file descriptor for |
34 // the pipe used to communicate the exit code of the process to Dart. | 33 // the pipe used to communicate the exit code of the process to Dart. |
35 // ProcessInfo objects are kept in the static singly-linked | 34 // ProcessInfo objects are kept in the static singly-linked |
36 // ProcessInfoList. | 35 // ProcessInfoList. |
37 class ProcessInfo { | 36 class ProcessInfo { |
38 public: | 37 public: |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 ReportChildError(); | 448 ReportChildError(); |
450 } | 449 } |
451 VOID_TEMP_FAILURE_RETRY(close(read_err_[1])); | 450 VOID_TEMP_FAILURE_RETRY(close(read_err_[1])); |
452 | 451 |
453 if (working_directory_ != NULL && | 452 if (working_directory_ != NULL && |
454 TEMP_FAILURE_RETRY(chdir(working_directory_)) == -1) { | 453 TEMP_FAILURE_RETRY(chdir(working_directory_)) == -1) { |
455 ReportChildError(); | 454 ReportChildError(); |
456 } | 455 } |
457 | 456 |
458 if (program_environment_ != NULL) { | 457 if (program_environment_ != NULL) { |
459 environ = program_environment_; | 458 // On MacOS you have to do a bit of magic to get to the |
| 459 // environment strings. |
| 460 char*** environ = _NSGetEnviron(); |
| 461 *environ = program_environment; |
460 } | 462 } |
461 | 463 |
462 VOID_TEMP_FAILURE_RETRY( | 464 VOID_TEMP_FAILURE_RETRY( |
463 execvp(path_, const_cast<char* const*>(program_arguments_))); | 465 execvp(path_, const_cast<char* const*>(program_arguments_))); |
464 | 466 |
465 ReportChildError(); | 467 ReportChildError(); |
466 } | 468 } |
467 | 469 |
468 | 470 |
469 void ExecDetachedProcess() { | 471 void ExecDetachedProcess() { |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 bzero(&act, sizeof(act)); | 1009 bzero(&act, sizeof(act)); |
1008 act.sa_handler = SIG_DFL; | 1010 act.sa_handler = SIG_DFL; |
1009 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); | 1011 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); |
1010 } | 1012 } |
1011 } | 1013 } |
1012 | 1014 |
1013 } // namespace bin | 1015 } // namespace bin |
1014 } // namespace dart | 1016 } // namespace dart |
1015 | 1017 |
1016 #endif // defined(TARGET_OS_MACOS) | 1018 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |