Index: runtime/bin/process_macos.cc |
diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc |
index 9f671a8bde5a2ec4c1552d7e4fc12667dff76b9e..584968e0821c2d7c8dbbe9ec14a4ecb4c5827df4 100644 |
--- a/runtime/bin/process_macos.cc |
+++ b/runtime/bin/process_macos.cc |
@@ -12,11 +12,11 @@ |
#if !TARGET_OS_IOS |
#include <crt_externs.h> // NOLINT |
#endif |
-#include <errno.h> // NOLINT |
-#include <fcntl.h> // NOLINT |
-#include <poll.h> // NOLINT |
+#include <errno.h> // NOLINT |
+#include <fcntl.h> // NOLINT |
+#include <poll.h> // NOLINT |
#include <signal.h> // NOLINT |
-#include <stdio.h> // NOLINT |
+#include <stdio.h> // NOLINT |
#include <stdlib.h> // NOLINT |
#include <string.h> // NOLINT |
#include <unistd.h> // NOLINT |
@@ -43,7 +43,7 @@ Process::ExitHook Process::exit_hook_ = NULL; |
// ProcessInfoList. |
class ProcessInfo { |
public: |
- ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) { } |
+ ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) {} |
~ProcessInfo() { |
int closed = TEMP_FAILURE_RETRY(close(fd_)); |
if (closed != 0) { |
@@ -207,7 +207,7 @@ class ExitCodeHandler { |
} |
intptr_t exit_code_fd = ProcessInfoList::LookupProcessExitFd(pid); |
if (exit_code_fd != 0) { |
- int message[2] = { exit_code, negative }; |
+ int message[2] = {exit_code, negative}; |
ssize_t result = |
FDUtils::WriteToBlocking(exit_code_fd, &message, sizeof(message)); |
// If the process has been closed, the read end of the exit |
@@ -562,8 +562,8 @@ class ProcessStarter { |
// 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. |
- bytes_read = FDUtils::ReadFromBlocking( |
- exec_control_[0], &child_errno, sizeof(child_errno)); |
+ bytes_read = FDUtils::ReadFromBlocking(exec_control_[0], &child_errno, |
+ sizeof(child_errno)); |
if (bytes_read == sizeof(child_errno)) { |
ReadChildError(); |
return child_errno; |
@@ -574,7 +574,7 @@ class ProcessStarter { |
} |
- int ReadDetachedExecResult(pid_t *pid) { |
+ int ReadDetachedExecResult(pid_t* pid) { |
int child_errno; |
int bytes_read = -1; |
// Read exec result from child. If only pid data is returned the exec was |
@@ -637,10 +637,8 @@ class ProcessStarter { |
max_fds = _POSIX_OPEN_MAX; |
} |
for (int fd = 0; fd < max_fds; fd++) { |
- if ((fd != exec_control_[1]) && |
- (fd != write_out_[0]) && |
- (fd != read_in_[1]) && |
- (fd != read_err_[1])) { |
+ if ((fd != exec_control_[1]) && (fd != write_out_[0]) && |
+ (fd != read_in_[1]) && (fd != read_err_[1])) { |
VOID_TEMP_FAILURE_RETRY(close(fd)); |
} |
} |
@@ -690,11 +688,11 @@ class ProcessStarter { |
const int kBufferSize = 1024; |
char os_error_message[kBufferSize]; |
Utils::StrError(errno, os_error_message, kBufferSize); |
- int bytes_written = FDUtils::WriteToBlocking( |
- exec_control_[1], &child_errno, sizeof(child_errno)); |
+ int bytes_written = FDUtils::WriteToBlocking(exec_control_[1], &child_errno, |
+ sizeof(child_errno)); |
if (bytes_written == sizeof(child_errno)) { |
- FDUtils::WriteToBlocking( |
- exec_control_[1], os_error_message, strlen(os_error_message) + 1); |
+ FDUtils::WriteToBlocking(exec_control_[1], os_error_message, |
+ strlen(os_error_message) + 1); |
} |
VOID_TEMP_FAILURE_RETRY(close(exec_control_[1])); |
exit(1); |
@@ -743,9 +741,9 @@ class ProcessStarter { |
} |
- int read_in_[2]; // Pipe for stdout to child process. |
- int read_err_[2]; // Pipe for stderr to child process. |
- int write_out_[2]; // Pipe for stdin to child process. |
+ int read_in_[2]; // Pipe for stdout to child process. |
+ int read_err_[2]; // Pipe for stderr to child process. |
+ int write_out_[2]; // Pipe for stdin to child process. |
int exec_control_[2]; // Pipe to get the result from exec. |
char** program_arguments_; |
@@ -779,24 +777,14 @@ int Process::Start(const char* path, |
intptr_t* id, |
intptr_t* exit_event, |
char** os_error_message) { |
- ProcessStarter starter(path, |
- arguments, |
- arguments_length, |
- working_directory, |
- environment, |
- environment_length, |
- mode, |
- in, |
- out, |
- err, |
- id, |
- exit_event, |
- os_error_message); |
+ ProcessStarter starter(path, arguments, arguments_length, working_directory, |
+ environment, environment_length, mode, in, out, err, |
+ id, exit_event, os_error_message); |
return starter.Start(); |
} |
-class BufferList: public BufferListBase { |
+class BufferList : public BufferListBase { |
public: |
BufferList() {} |
@@ -809,10 +797,8 @@ class BufferList: public BufferListBase { |
ASSERT(free_size_ > 0); |
ASSERT(free_size_ <= kBufferSize); |
size_t block_size = dart::Utils::Minimum(free_size_, available); |
- ssize_t bytes = TEMP_FAILURE_RETRY(read( |
- fd, |
- reinterpret_cast<void*>(FreeSpaceAddress()), |
- block_size)); |
+ ssize_t bytes = TEMP_FAILURE_RETRY( |
+ read(fd, reinterpret_cast<void*>(FreeSpaceAddress()), block_size)); |
if (bytes < 0) { |
return false; |
} |
@@ -892,8 +878,8 @@ bool Process::Wait(intptr_t pid, |
} |
} else if (fds[i].fd == exit_event) { |
if (avail == 8) { |
- intptr_t b = TEMP_FAILURE_RETRY(read(fds[i].fd, |
- exit_code_data.bytes, 8)); |
+ intptr_t b = |
+ TEMP_FAILURE_RETRY(read(fds[i].fd, exit_code_data.bytes, 8)); |
if (b != 8) { |
return CloseProcessBuffers(fds); |
} |
@@ -932,35 +918,64 @@ bool Process::Wait(intptr_t pid, |
static int SignalMap(intptr_t id) { |
switch (static_cast<ProcessSignals>(id)) { |
- case kSighup: return SIGHUP; |
- case kSigint: return SIGINT; |
- case kSigquit: return SIGQUIT; |
- case kSigill: return SIGILL; |
- case kSigtrap: return SIGTRAP; |
- case kSigabrt: return SIGABRT; |
- case kSigbus: return SIGBUS; |
- case kSigfpe: return SIGFPE; |
- case kSigkill: return SIGKILL; |
- case kSigusr1: return SIGUSR1; |
- case kSigsegv: return SIGSEGV; |
- case kSigusr2: return SIGUSR2; |
- case kSigpipe: return SIGPIPE; |
- case kSigalrm: return SIGALRM; |
- case kSigterm: return SIGTERM; |
- case kSigchld: return SIGCHLD; |
- case kSigcont: return SIGCONT; |
- case kSigstop: return SIGSTOP; |
- case kSigtstp: return SIGTSTP; |
- case kSigttin: return SIGTTIN; |
- case kSigttou: return SIGTTOU; |
- case kSigurg: return SIGURG; |
- case kSigxcpu: return SIGXCPU; |
- case kSigxfsz: return SIGXFSZ; |
- case kSigvtalrm: return SIGVTALRM; |
- case kSigprof: return SIGPROF; |
- case kSigwinch: return SIGWINCH; |
- case kSigpoll: return -1; |
- case kSigsys: return SIGSYS; |
+ case kSighup: |
+ return SIGHUP; |
+ case kSigint: |
+ return SIGINT; |
+ case kSigquit: |
+ return SIGQUIT; |
+ case kSigill: |
+ return SIGILL; |
+ case kSigtrap: |
+ return SIGTRAP; |
+ case kSigabrt: |
+ return SIGABRT; |
+ case kSigbus: |
+ return SIGBUS; |
+ case kSigfpe: |
+ return SIGFPE; |
+ case kSigkill: |
+ return SIGKILL; |
+ case kSigusr1: |
+ return SIGUSR1; |
+ case kSigsegv: |
+ return SIGSEGV; |
+ case kSigusr2: |
+ return SIGUSR2; |
+ case kSigpipe: |
+ return SIGPIPE; |
+ case kSigalrm: |
+ return SIGALRM; |
+ case kSigterm: |
+ return SIGTERM; |
+ case kSigchld: |
+ return SIGCHLD; |
+ case kSigcont: |
+ return SIGCONT; |
+ case kSigstop: |
+ return SIGSTOP; |
+ case kSigtstp: |
+ return SIGTSTP; |
+ case kSigttin: |
+ return SIGTTIN; |
+ case kSigttou: |
+ return SIGTTOU; |
+ case kSigurg: |
+ return SIGURG; |
+ case kSigxcpu: |
+ return SIGXCPU; |
+ case kSigxfsz: |
+ return SIGXFSZ; |
+ case kSigvtalrm: |
+ return SIGVTALRM; |
+ case kSigprof: |
+ return SIGPROF; |
+ case kSigwinch: |
+ return SIGWINCH; |
+ case kSigpoll: |
+ return -1; |
+ case kSigsys: |
+ return SIGSYS; |
} |
return -1; |
} |
@@ -985,13 +1000,8 @@ static Mutex* signal_mutex = new Mutex(); |
static SignalInfo* signal_handlers = NULL; |
static const int kSignalsCount = 7; |
static const int kSignals[kSignalsCount] = { |
- SIGHUP, |
- SIGINT, |
- SIGTERM, |
- SIGUSR1, |
- SIGUSR2, |
- SIGWINCH, |
- SIGQUIT // Allow VMService to listen on SIGQUIT. |
+ SIGHUP, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGWINCH, |
+ SIGQUIT // Allow VMService to listen on SIGQUIT. |
}; |
@@ -1032,8 +1042,7 @@ intptr_t Process::SetSignalHandler(intptr_t signal) { |
if (NO_RETRY_EXPECTED(pipe(fds)) != 0) { |
return -1; |
} |
- if (!FDUtils::SetCloseOnExec(fds[0]) || |
- !FDUtils::SetCloseOnExec(fds[1]) || |
+ if (!FDUtils::SetCloseOnExec(fds[0]) || !FDUtils::SetCloseOnExec(fds[1]) || |
!FDUtils::SetNonBlocking(fds[0])) { |
VOID_TEMP_FAILURE_RETRY(close(fds[0])); |
VOID_TEMP_FAILURE_RETRY(close(fds[1])); |