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

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

Issue 23717038: Simplify process exit-code handling on Posix, take 2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename and fix mac & android. Created 7 years, 3 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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/platform.h" 8 #include "bin/platform.h"
9 9
10 #include <signal.h> // NOLINT 10 #include <signal.h> // NOLINT
11 #include <string.h> // NOLINT 11 #include <string.h> // NOLINT
12 #include <unistd.h> // NOLINT 12 #include <unistd.h> // NOLINT
13 13
14 14
15 namespace dart { 15 namespace dart {
16 namespace bin { 16 namespace bin {
17 17
18 bool Platform::Initialize() { 18 bool Platform::Initialize() {
19 // Turn off the signal handler for SIGPIPE as it causes the process 19 // Turn off the signal handler for SIGPIPE as it causes the process
20 // to terminate on writing to a closed pipe. Without the signal 20 // to terminate on writing to a closed pipe. Without the signal
21 // handler error EPIPE is set instead. 21 // handler error EPIPE is set instead.
22 struct sigaction act; 22 struct sigaction act;
23 bzero(&act, sizeof(act)); 23 bzero(&act, sizeof(act));
24 act.sa_handler = SIG_IGN; 24 act.sa_handler = SIG_IGN;
25 if (sigaction(SIGPIPE, &act, 0) != 0) { 25 if (sigaction(SIGPIPE, &act, 0) != 0) {
26 perror("Setting signal handler failed"); 26 perror("Setting signal handler failed");
27 return false; 27 return false;
28 } 28 }
29 // Unblock SIGCHLD as waiting on spawned child process depends
30 // on successful interception of this signal.
31 sigset_t newset;
32 sigemptyset(&newset);
33 sigaddset(&newset, SIGCHLD);
34 if (sigprocmask(SIG_UNBLOCK, &newset, NULL) != 0) {
35 perror("Unblocking SIGCHLD signal failed");
36 }
37 return true; 29 return true;
38 } 30 }
39 31
40 32
41 int Platform::NumberOfProcessors() { 33 int Platform::NumberOfProcessors() {
42 return sysconf(_SC_NPROCESSORS_ONLN); 34 return sysconf(_SC_NPROCESSORS_ONLN);
43 } 35 }
44 36
45 37
46 const char* Platform::OperatingSystem() { 38 const char* Platform::OperatingSystem() {
(...skipping 22 matching lines...) Expand all
69 61
70 62
71 void Platform::FreeEnvironment(char** env, intptr_t count) { 63 void Platform::FreeEnvironment(char** env, intptr_t count) {
72 delete[] env; 64 delete[] env;
73 } 65 }
74 66
75 } // namespace bin 67 } // namespace bin
76 } // namespace dart 68 } // namespace dart
77 69
78 #endif // defined(TARGET_OS_LINUX) 70 #endif // defined(TARGET_OS_LINUX)
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