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

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

Issue 11571056: Set close-on-exec flag on pipe() and kqueue() file descriptors on MacOS (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | runtime/bin/process_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/eventhandler.h" 5 #include "bin/eventhandler.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 117
118 EventHandlerImplementation::EventHandlerImplementation() 118 EventHandlerImplementation::EventHandlerImplementation()
119 : socket_map_(&HashMap::SamePointerValue, 16) { 119 : socket_map_(&HashMap::SamePointerValue, 16) {
120 intptr_t result; 120 intptr_t result;
121 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); 121 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_));
122 if (result != 0) { 122 if (result != 0) {
123 FATAL("Pipe creation failed"); 123 FATAL("Pipe creation failed");
124 } 124 }
125 FDUtils::SetNonBlocking(interrupt_fds_[0]); 125 FDUtils::SetNonBlocking(interrupt_fds_[0]);
126 FDUtils::SetCloseOnExec(interrupt_fds_[0]);
127 FDUtils::SetCloseOnExec(interrupt_fds_[1]);
126 timeout_ = kInfinityTimeout; 128 timeout_ = kInfinityTimeout;
127 timeout_port_ = 0; 129 timeout_port_ = 0;
128 shutdown_ = false; 130 shutdown_ = false;
129 131
130 kqueue_fd_ = TEMP_FAILURE_RETRY(kqueue()); 132 kqueue_fd_ = TEMP_FAILURE_RETRY(kqueue());
131 if (kqueue_fd_ == -1) { 133 if (kqueue_fd_ == -1) {
132 FATAL("Failed creating kqueue"); 134 FATAL("Failed creating kqueue");
133 } 135 }
136 FDUtils::SetCloseOnExec(kqueue_fd_);
134 // Register the interrupt_fd with the kqueue. 137 // Register the interrupt_fd with the kqueue.
135 struct kevent event; 138 struct kevent event;
136 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL); 139 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL);
137 int status = TEMP_FAILURE_RETRY(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); 140 int status = TEMP_FAILURE_RETRY(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL));
138 if (status == -1) { 141 if (status == -1) {
139 FATAL1("Failed adding interrupt fd to kqueue: %s\n", strerror(errno)); 142 FATAL1("Failed adding interrupt fd to kqueue: %s\n", strerror(errno));
140 } 143 }
141 } 144 }
142 145
143 146
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { 418 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) {
416 // The hashmap does not support keys with value 0. 419 // The hashmap does not support keys with value 0.
417 return reinterpret_cast<void*>(fd + 1); 420 return reinterpret_cast<void*>(fd + 1);
418 } 421 }
419 422
420 423
421 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 424 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
422 // The hashmap does not support keys with value 0. 425 // The hashmap does not support keys with value 0.
423 return dart::Utils::WordHash(fd + 1); 426 return dart::Utils::WordHash(fd + 1);
424 } 427 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698