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

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

Issue 12576007: Fix of file descriptor inheritance problem in process_{linux,android,mac} (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/process_android.cc ('k') | 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 "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/process.h" 8 #include "bin/process.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 *os_error_message); 329 *os_error_message);
330 return errno; 330 return errno;
331 } 331 }
332 332
333 result = TEMP_FAILURE_RETRY(pipe(read_in)); 333 result = TEMP_FAILURE_RETRY(pipe(read_in));
334 if (result < 0) { 334 if (result < 0) {
335 SetChildOsErrorMessage(os_error_message); 335 SetChildOsErrorMessage(os_error_message);
336 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); 336 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
337 return errno; 337 return errno;
338 } 338 }
339 FDUtils::SetCloseOnExec(read_in[0]);
339 340
340 result = TEMP_FAILURE_RETRY(pipe(read_err)); 341 result = TEMP_FAILURE_RETRY(pipe(read_err));
341 if (result < 0) { 342 if (result < 0) {
342 SetChildOsErrorMessage(os_error_message); 343 SetChildOsErrorMessage(os_error_message);
343 TEMP_FAILURE_RETRY(close(read_in[0])); 344 TEMP_FAILURE_RETRY(close(read_in[0]));
344 TEMP_FAILURE_RETRY(close(read_in[1])); 345 TEMP_FAILURE_RETRY(close(read_in[1]));
345 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); 346 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
346 return errno; 347 return errno;
347 } 348 }
349 FDUtils::SetCloseOnExec(read_err[0]);
348 350
349 result = TEMP_FAILURE_RETRY(pipe(write_out)); 351 result = TEMP_FAILURE_RETRY(pipe(write_out));
350 if (result < 0) { 352 if (result < 0) {
351 SetChildOsErrorMessage(os_error_message); 353 SetChildOsErrorMessage(os_error_message);
352 TEMP_FAILURE_RETRY(close(read_in[0])); 354 TEMP_FAILURE_RETRY(close(read_in[0]));
353 TEMP_FAILURE_RETRY(close(read_in[1])); 355 TEMP_FAILURE_RETRY(close(read_in[1]));
354 TEMP_FAILURE_RETRY(close(read_err[0])); 356 TEMP_FAILURE_RETRY(close(read_err[0]));
355 TEMP_FAILURE_RETRY(close(read_err[1])); 357 TEMP_FAILURE_RETRY(close(read_err[1]));
356 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); 358 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
357 return errno; 359 return errno;
358 } 360 }
361 FDUtils::SetCloseOnExec(write_out[1]);
359 362
360 result = TEMP_FAILURE_RETRY(pipe(exec_control)); 363 result = TEMP_FAILURE_RETRY(pipe(exec_control));
361 if (result < 0) { 364 if (result < 0) {
362 SetChildOsErrorMessage(os_error_message); 365 SetChildOsErrorMessage(os_error_message);
363 TEMP_FAILURE_RETRY(close(read_in[0])); 366 TEMP_FAILURE_RETRY(close(read_in[0]));
364 TEMP_FAILURE_RETRY(close(read_in[1])); 367 TEMP_FAILURE_RETRY(close(read_in[1]));
365 TEMP_FAILURE_RETRY(close(read_err[0])); 368 TEMP_FAILURE_RETRY(close(read_err[0]));
366 TEMP_FAILURE_RETRY(close(read_err[1])); 369 TEMP_FAILURE_RETRY(close(read_err[1]));
367 TEMP_FAILURE_RETRY(close(write_out[0])); 370 TEMP_FAILURE_RETRY(close(write_out[0]));
368 TEMP_FAILURE_RETRY(close(write_out[1])); 371 TEMP_FAILURE_RETRY(close(write_out[1]));
369 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); 372 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
370 return errno; 373 return errno;
371 } 374 }
375 FDUtils::SetCloseOnExec(exec_control[0]);
376 FDUtils::SetCloseOnExec(exec_control[1]);
372 377
373 // Set close on exec on the write file descriptor of the exec control pipe.
374 result = TEMP_FAILURE_RETRY(
375 fcntl(exec_control[1],
376 F_SETFD,
377 TEMP_FAILURE_RETRY(fcntl(exec_control[1], F_GETFD)) | FD_CLOEXEC));
378 if (result < 0) { 378 if (result < 0) {
379 SetChildOsErrorMessage(os_error_message); 379 SetChildOsErrorMessage(os_error_message);
380 TEMP_FAILURE_RETRY(close(read_in[0])); 380 TEMP_FAILURE_RETRY(close(read_in[0]));
381 TEMP_FAILURE_RETRY(close(read_in[1])); 381 TEMP_FAILURE_RETRY(close(read_in[1]));
382 TEMP_FAILURE_RETRY(close(read_err[0])); 382 TEMP_FAILURE_RETRY(close(read_err[0]));
383 TEMP_FAILURE_RETRY(close(read_err[1])); 383 TEMP_FAILURE_RETRY(close(read_err[1]));
384 TEMP_FAILURE_RETRY(close(write_out[0])); 384 TEMP_FAILURE_RETRY(close(write_out[0]));
385 TEMP_FAILURE_RETRY(close(write_out[1])); 385 TEMP_FAILURE_RETRY(close(write_out[1]));
386 TEMP_FAILURE_RETRY(close(exec_control[0])); 386 TEMP_FAILURE_RETRY(close(exec_control[0]));
387 TEMP_FAILURE_RETRY(close(exec_control[1])); 387 TEMP_FAILURE_RETRY(close(exec_control[1]));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 void Process::TerminateExitCodeHandler() { 560 void Process::TerminateExitCodeHandler() {
561 ExitCodeHandler::TerminateExitCodeThread(); 561 ExitCodeHandler::TerminateExitCodeThread();
562 } 562 }
563 563
564 564
565 intptr_t Process::CurrentProcessId() { 565 intptr_t Process::CurrentProcessId() {
566 return static_cast<intptr_t>(getpid()); 566 return static_cast<intptr_t>(getpid());
567 } 567 }
568 568
569 #endif // defined(TARGET_OS_LINUX) 569 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698