Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: implement os.release() using uv_os_uname() #25600

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 5 additions & 33 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,44 +105,16 @@ static void GetOSType(const FunctionCallbackInfo<Value>& args) {

static void GetOSRelease(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
const char* rval;
uv_utsname_t info;
int err = uv_os_uname(&info);

#ifdef __POSIX__
struct utsname info;
if (uname(&info) < 0) {
if (err != 0) {
CHECK_GE(args.Length(), 1);
env->CollectExceptionInfo(args[args.Length() - 1], errno, "uname");
env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_os_uname");
return args.GetReturnValue().SetUndefined();
}
# ifdef _AIX
char release[256];
snprintf(release, sizeof(release),
"%s.%s", info.version, info.release);
rval = release;
# else
rval = info.release;
# endif
#else // Windows
char release[256];
OSVERSIONINFOW info;

info.dwOSVersionInfoSize = sizeof(info);

// Don't complain that GetVersionEx is deprecated; there is no alternative.
#pragma warning(suppress : 4996)
if (GetVersionExW(&info) == 0)
return;

snprintf(release,
sizeof(release),
"%d.%d.%d",
static_cast<int>(info.dwMajorVersion),
static_cast<int>(info.dwMinorVersion),
static_cast<int>(info.dwBuildNumber));
rval = release;
#endif // __POSIX__

args.GetReturnValue().Set(OneByteString(env->isolate(), rval));
args.GetReturnValue().Set(OneByteString(env->isolate(), info.release));
}


Expand Down