d7c8c1f1e4
1. Ignore the signal SIGPIPE on Linux and Mac OS When reading from or writing to a closed pipe the signal SIGPIPE is raised. The default handling of this is to terminate the program. When signal SIGPIPE is ignored the read and write returns EPIPE. 2. Wrong return type for stdio getter 3. When there is an error on a socket mark it as closed 4. Mark the pipe used for process exit status as a one way pipe 5. Add tests to test stdin, stdout and stderr in Dart scripts R=ager@google.com BUG=dart:536, dart:454 TEST= Review URL: http://codereview.chromium.org//8662006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1793 260f80e4-7a28-3924-810f-c04153c831b5
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "bin/platform.h"
|
|
|
|
|
|
bool Platform::Initialize() {
|
|
// Nothing to do on Windows.
|
|
return true;
|
|
}
|
|
|
|
|
|
int Platform::NumberOfProcessors() {
|
|
SYSTEM_INFO info;
|
|
GetSystemInfo(&info);
|
|
return info.dwNumberOfProcessors;
|
|
}
|
|
|
|
|
|
const char* Platform::OperatingSystem() {
|
|
return "windows";
|
|
}
|
|
|
|
|
|
char* Platform::StrError(int error_code) {
|
|
static const int kBufferSize = 1024;
|
|
char* error = static_cast<char*>(malloc(kBufferSize));
|
|
DWORD message_size =
|
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
NULL,
|
|
error_code,
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
error,
|
|
kBufferSize,
|
|
NULL);
|
|
if (message_size == 0) {
|
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
|
fprintf(stderr, "FormatMessage failed %d\n", GetLastError());
|
|
}
|
|
snprintf(error, kBufferSize, "OS Error %d", error_code);
|
|
}
|
|
// Strip out \r\n at the end of the generated message and ensure
|
|
// null termination.
|
|
if (message_size > 2 &&
|
|
error[message_size - 2] == '\r' &&
|
|
error[message_size - 1] == '\n') {
|
|
error[message_size - 2] = '\0';
|
|
} else {
|
|
error[kBufferSize - 1] = '\0';
|
|
}
|
|
return error;
|
|
}
|