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

Side by Side Diff: runtime/bin/platform_linux.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_android.cc ('k') | runtime/bin/platform_macos.cc » ('j') | 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 <signal.h> 7 #include <signal.h>
8 #include <string.h> 8 #include <string.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 11
12 bool Platform::Initialize() { 12 bool Platform::Initialize() {
13 // Turn off the signal handler for SIGPIPE as it causes the process 13 // Turn off the signal handler for SIGPIPE as it causes the process
14 // to terminate on writing to a closed pipe. Without the signal 14 // to terminate on writing to a closed pipe. Without the signal
15 // handler error EPIPE is set instead. 15 // handler error EPIPE is set instead.
16 struct sigaction act; 16 struct sigaction act;
17 bzero(&act, sizeof(act)); 17 bzero(&act, sizeof(act));
18 act.sa_handler = SIG_IGN; 18 act.sa_handler = SIG_IGN;
19 if (sigaction(SIGPIPE, &act, 0) != 0) { 19 if (sigaction(SIGPIPE, &act, 0) != 0) {
20 perror("Setting signal handler failed"); 20 perror("Setting signal handler failed");
21 return false; 21 return false;
22 } 22 }
23 // Unblock SIGCHLD as waiting on spawned child process depends
24 // on successful interception of this signal.
25 sigset_t newset;
26 sigemptyset(&newset);
27 sigaddset(&newset, SIGCHLD);
28 if (sigprocmask(SIG_UNBLOCK, &newset, NULL) != 0) {
29 perror("Unblocking SIGCHLD signal failed");
30 }
23 return true; 31 return true;
24 } 32 }
25 33
26 34
27 int Platform::NumberOfProcessors() { 35 int Platform::NumberOfProcessors() {
28 return sysconf(_SC_NPROCESSORS_ONLN); 36 return sysconf(_SC_NPROCESSORS_ONLN);
29 } 37 }
30 38
31 39
32 const char* Platform::OperatingSystem() { 40 const char* Platform::OperatingSystem() {
(...skipping 25 matching lines...) Expand all
58 static const int kBufferSize = 1024; 66 static const int kBufferSize = 1024;
59 char* error = static_cast<char*>(malloc(kBufferSize)); 67 char* error = static_cast<char*>(malloc(kBufferSize));
60 error[0] = '\0'; 68 error[0] = '\0';
61 char* error_str = strerror_r(error_code, error, kBufferSize); 69 char* error_str = strerror_r(error_code, error, kBufferSize);
62 if (error_str != error) { 70 if (error_str != error) {
63 size_t written = snprintf(error, kBufferSize, "%s", error_str); 71 size_t written = snprintf(error, kBufferSize, "%s", error_str);
64 ASSERT(written == strlen(error_str)); 72 ASSERT(written == strlen(error_str));
65 } 73 }
66 return error; 74 return error;
67 } 75 }
OLDNEW
« no previous file with comments | « runtime/bin/platform_android.cc ('k') | runtime/bin/platform_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698