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

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

Issue 8659032: Fix memory leak in MacOS process handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/process.h" 5 #include "bin/process.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (bytes_read != sizeof(msg)) { 223 if (bytes_read != sizeof(msg)) {
224 perror("Failed receiving notification message"); 224 perror("Failed receiving notification message");
225 exit(1); 225 exit(1);
226 } 226 }
227 227
228 close(write_out[1]); 228 close(write_out[1]);
229 close(read_in[0]); 229 close(read_in[0]);
230 close(read_err[0]); 230 close(read_err[0]);
231 close(exec_control[0]); 231 close(exec_control[0]);
232 232
233 dup2(write_out[0], STDIN_FILENO); 233 if (dup2(write_out[0], STDIN_FILENO) == -1) {
Søren Gjesse 2011/11/29 09:39:25 As this is in the child process the output of thes
Mads Ager (google) 2011/11/29 10:10:13 Yes, refactored the code after execvp into a Repor
234 perror("Failed to dup stdin");
235 }
234 close(write_out[0]); 236 close(write_out[0]);
235 237
236 dup2(read_in[1], STDOUT_FILENO); 238 if (dup2(read_in[1], STDOUT_FILENO) == -1) {
239 perror("Failed to dup stdout");
240 }
237 close(read_in[1]); 241 close(read_in[1]);
238 242
239 dup2(read_err[1], STDERR_FILENO); 243 if (dup2(read_err[1], STDERR_FILENO) == -1) {
244 perror("Failed to dup stderr");
245 }
240 close(read_err[1]); 246 close(read_err[1]);
241 247
242 execvp(path, const_cast<char* const*>(program_arguments)); 248 execvp(path, const_cast<char* const*>(program_arguments));
243 // In the case of failure write the errno and the OS error message 249 // In the case of failure write the errno and the OS error message
244 // to the exec control pipe. 250 // to the exec control pipe.
245 int child_errno = errno; 251 int child_errno = errno;
246 char* os_error_message = strerror(errno); 252 char* os_error_message = strerror(errno);
247 ASSERT(sizeof(child_errno) == sizeof(errno)); 253 ASSERT(sizeof(child_errno) == sizeof(errno));
248 int bytes_written = 254 int bytes_written =
249 FDUtils::WriteToBlocking( 255 FDUtils::WriteToBlocking(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (result == -1) { 344 if (result == -1) {
339 return false; 345 return false;
340 } 346 }
341 return true; 347 return true;
342 } 348 }
343 349
344 350
345 void Process::Exit(intptr_t id) { 351 void Process::Exit(intptr_t id) {
346 RemoveProcess(id); 352 RemoveProcess(id);
347 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698