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

Unified Diff: runtime/bin/process_linux.cc

Issue 165723007: Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tiny fix. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_linux.cc
diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc
index e2810fc6dc17a4c37f52e25ad50abdf9db371ace..844d09e4659a3005c66e9e5055e716cb91ac5474 100644
--- a/runtime/bin/process_linux.cc
+++ b/runtime/bin/process_linux.cc
@@ -16,9 +16,9 @@
#include <sys/wait.h> // NOLINT
#include <unistd.h> // NOLINT
+#include "platform/signal_blocker.h"
#include "bin/fdutils.h"
#include "bin/log.h"
-#include "bin/signal_blocker.h"
#include "bin/thread.h"
@@ -151,7 +151,7 @@ class ExitCodeHandler {
running_ = false;
// Fork to wake up waitpid.
- if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS(fork()) == 0) {
+ if (TEMP_FAILURE_RETRY(fork()) == 0) {
exit(0);
}
@@ -250,7 +250,7 @@ static void ReportChildError(int exec_control_fd) {
FDUtils::WriteToBlocking(
exec_control_fd, os_error_message, strlen(os_error_message) + 1);
}
- TEMP_FAILURE_RETRY(close(exec_control_fd));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control_fd));
exit(1);
}
@@ -274,7 +274,7 @@ int Process::Start(const char* path,
int exec_control[2]; // Pipe to get the result from exec.
int result;
- result = TEMP_FAILURE_RETRY(pipe(read_in));
+ result = pipe(read_in);
if (result < 0) {
SetChildOsErrorMessage(os_error_message);
Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
@@ -282,37 +282,37 @@ int Process::Start(const char* path,
}
FDUtils::SetCloseOnExec(read_in[0]);
- result = TEMP_FAILURE_RETRY(pipe(read_err));
+ result = pipe(read_err);
if (result < 0) {
SetChildOsErrorMessage(os_error_message);
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
return errno;
}
FDUtils::SetCloseOnExec(read_err[0]);
- result = TEMP_FAILURE_RETRY(pipe(write_out));
+ result = pipe(write_out);
if (result < 0) {
SetChildOsErrorMessage(os_error_message);
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
return errno;
}
FDUtils::SetCloseOnExec(write_out[1]);
- result = TEMP_FAILURE_RETRY(pipe(exec_control));
+ result = pipe(exec_control);
if (result < 0) {
SetChildOsErrorMessage(os_error_message);
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(read_err[1]));
- TEMP_FAILURE_RETRY(close(write_out[0]));
- TEMP_FAILURE_RETRY(close(write_out[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
return errno;
}
@@ -321,14 +321,14 @@ int Process::Start(const char* path,
if (result < 0) {
SetChildOsErrorMessage(os_error_message);
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(read_err[1]));
- TEMP_FAILURE_RETRY(close(write_out[0]));
- TEMP_FAILURE_RETRY(close(write_out[1]));
- TEMP_FAILURE_RETRY(close(exec_control[0]));
- TEMP_FAILURE_RETRY(close(exec_control[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[0]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[1]));
Log::PrintErr("fcntl failed: %s\n", *os_error_message);
return errno;
}
@@ -349,18 +349,18 @@ int Process::Start(const char* path,
program_environment[environment_length] = NULL;
}
- pid = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(fork());
+ pid = TEMP_FAILURE_RETRY(fork());
if (pid < 0) {
SetChildOsErrorMessage(os_error_message);
delete[] program_arguments;
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(read_err[1]));
- TEMP_FAILURE_RETRY(close(write_out[0]));
- TEMP_FAILURE_RETRY(close(write_out[1]));
- TEMP_FAILURE_RETRY(close(exec_control[0]));
- TEMP_FAILURE_RETRY(close(exec_control[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[0]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[1]));
return errno;
} else if (pid == 0) {
// Wait for parent process before setting up the child process.
@@ -371,28 +371,27 @@ int Process::Start(const char* path,
exit(1);
}
- TEMP_FAILURE_RETRY(close(write_out[1]));
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(exec_control[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[0]));
if (TEMP_FAILURE_RETRY(dup2(write_out[0], STDIN_FILENO)) == -1) {
ReportChildError(exec_control[1]);
}
- TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
if (TEMP_FAILURE_RETRY(dup2(read_in[1], STDOUT_FILENO)) == -1) {
ReportChildError(exec_control[1]);
}
- TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) {
ReportChildError(exec_control[1]);
}
- TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
- if (working_directory != NULL &&
- TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) {
+ if (working_directory != NULL && chdir(working_directory) == -1) {
ReportChildError(exec_control[1]);
}
@@ -400,8 +399,7 @@ int Process::Start(const char* path,
environ = program_environment;
}
- TEMP_FAILURE_RETRY(
- execvp(path, const_cast<char* const*>(program_arguments)));
+ execvp(path, const_cast<char* const*>(program_arguments));
ReportChildError(exec_control[1]);
}
@@ -415,15 +413,15 @@ int Process::Start(const char* path,
delete[] program_environment;
int event_fds[2];
- result = TEMP_FAILURE_RETRY(pipe(event_fds));
+ result = pipe(event_fds);
if (result < 0) {
SetChildOsErrorMessage(os_error_message);
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(read_err[1]));
- TEMP_FAILURE_RETRY(close(write_out[0]));
- TEMP_FAILURE_RETRY(close(write_out[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
return errno;
}
@@ -444,7 +442,7 @@ int Process::Start(const char* path,
// Read exec result from child. If no data is returned the exec was
// successful and the exec call closed the pipe. Otherwise the errno
// is written to the pipe.
- TEMP_FAILURE_RETRY(close(exec_control[1]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[1]));
int child_errno;
int bytes_read = -1;
ASSERT(sizeof(child_errno) == sizeof(errno));
@@ -460,22 +458,22 @@ int Process::Start(const char* path,
message[kMaxMessageSize - 1] = '\0';
*os_error_message = message;
}
- TEMP_FAILURE_RETRY(close(exec_control[0]));
+ VOID_TEMP_FAILURE_RETRY(close(exec_control[0]));
// Return error code if any failures.
if (bytes_read != 0) {
- TEMP_FAILURE_RETRY(close(read_in[0]));
- TEMP_FAILURE_RETRY(close(read_in[1]));
- TEMP_FAILURE_RETRY(close(read_err[0]));
- TEMP_FAILURE_RETRY(close(read_err[1]));
- TEMP_FAILURE_RETRY(close(write_out[0]));
- TEMP_FAILURE_RETRY(close(write_out[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
// Since exec() failed, we're not interested in the exit code.
// We close the reading side of the exit code pipe here.
// GetProcessExitCodes will get a broken pipe error when it tries to write
// to the writing side of the pipe and it will ignore the error.
- TEMP_FAILURE_RETRY(close(*exit_event));
+ VOID_TEMP_FAILURE_RETRY(close(*exit_event));
*exit_event = -1;
if (bytes_read == -1) {
@@ -487,13 +485,13 @@ int Process::Start(const char* path,
FDUtils::SetNonBlocking(read_in[0]);
*in = read_in[0];
- TEMP_FAILURE_RETRY(close(read_in[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
FDUtils::SetNonBlocking(write_out[1]);
*out = write_out[1];
- TEMP_FAILURE_RETRY(close(write_out[0]));
+ VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
FDUtils::SetNonBlocking(read_err[0]);
*err = read_err[0];
- TEMP_FAILURE_RETRY(close(read_err[1]));
+ VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
*id = pid;
return 0;
@@ -618,7 +616,7 @@ bool Process::Wait(intptr_t pid,
bool Process::Kill(intptr_t id, int signal) {
- return (TEMP_FAILURE_RETRY(kill(id, signal)) != -1);
+ return kill(id, signal) != -1;
}
@@ -673,12 +671,12 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
}
if (!found) return -1;
int fds[2];
- if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS(pipe(fds)) != 0) {
+ if (pipe(fds) != 0) {
return -1;
}
if (!FDUtils::SetNonBlocking(fds[0])) {
- VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fds[0]));
- VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fds[1]));
+ VOID_TEMP_FAILURE_RETRY(close(fds[0]));
+ VOID_TEMP_FAILURE_RETRY(close(fds[1]));
return -1;
}
ThreadSignalBlocker blocker(kSignalsCount, kSignals);
@@ -700,11 +698,10 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
for (int i = 0; i < kSignalsCount; i++) {
sigaddset(&act.sa_mask, kSignals[i]);
}
- int status = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(
- sigaction(signal, &act, NULL));
+ int status = sigaction(signal, &act, NULL);
if (status < 0) {
- VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fds[0]));
- VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fds[1]));
+ VOID_TEMP_FAILURE_RETRY(close(fds[0]));
+ VOID_TEMP_FAILURE_RETRY(close(fds[1]));
return -1;
}
}
@@ -741,7 +738,7 @@ void Process::ClearSignalHandler(intptr_t signal) {
struct sigaction act;
bzero(&act, sizeof(act));
act.sa_handler = SIG_DFL;
- VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(sigaction(signal, &act, NULL));
+ sigaction(signal, &act, NULL);
}
}
« 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