Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: runtime/bin/platform_macos.cc

Issue 10834423: Fix for bug dart 3639: Process.run gets stuck on Mac (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added periods Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/platform_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bin/platform.h" 5 #include "bin/platform.h"
6 6
7 #include <crt_externs.h> 7 #include <crt_externs.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <string.h> 9 #include <string.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 12
13 bool Platform::Initialize() { 13 bool Platform::Initialize() {
14 // Turn off the signal handler for SIGPIPE as it causes the process 14 // Turn off the signal handler for SIGPIPE as it causes the process
15 // to terminate on writing to a closed pipe. Without the signal 15 // to terminate on writing to a closed pipe. Without the signal
16 // handler error EPIPE is set instead. 16 // handler error EPIPE is set instead.
17 struct sigaction act; 17 struct sigaction act;
18 bzero(&act, sizeof(act)); 18 bzero(&act, sizeof(act));
19 act.sa_handler = SIG_IGN; 19 act.sa_handler = SIG_IGN;
20 if (sigaction(SIGPIPE, &act, 0) != 0) { 20 if (sigaction(SIGPIPE, &act, 0) != 0) {
21 perror("Setting signal handler failed"); 21 perror("Setting signal handler failed");
22 return false; 22 return false;
23 } 23 }
24 // Unblock SIGCHLD as waiting on spawned child process depends
25 // on successful interception of this signal.
26 sigset_t newset;
27 sigemptyset(&newset);
28 sigaddset(&newset, SIGCHLD);
29 if (sigprocmask(SIG_UNBLOCK, &newset, NULL) != 0) {
30 perror("Unblocking SIGCHLD signal failed");
31 }
32
24 return true; 33 return true;
25 } 34 }
26 35
27 36
28 int Platform::NumberOfProcessors() { 37 int Platform::NumberOfProcessors() {
29 return sysconf(_SC_NPROCESSORS_ONLN); 38 return sysconf(_SC_NPROCESSORS_ONLN);
30 } 39 }
31 40
32 41
33 const char* Platform::OperatingSystem() { 42 const char* Platform::OperatingSystem() {
(...skipping 24 matching lines...) Expand all
58 } 67 }
59 68
60 69
61 char* Platform::StrError(int error_code) { 70 char* Platform::StrError(int error_code) {
62 static const int kBufferSize = 1024; 71 static const int kBufferSize = 1024;
63 char* error = static_cast<char*>(malloc(kBufferSize)); 72 char* error = static_cast<char*>(malloc(kBufferSize));
64 error[0] = '\0'; 73 error[0] = '\0';
65 strerror_r(error_code, error, kBufferSize); 74 strerror_r(error_code, error, kBufferSize);
66 return error; 75 return error;
67 } 76 }
OLDNEW
« no previous file with comments | « runtime/bin/platform_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698