diff --git a/src/node_os.cc b/src/node_os.cc index a5ae53ba75ee3c..5639453d2c46ed 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -36,7 +36,6 @@ # include // MAXHOSTNAMELEN on Solaris. # include // gethostname, sysconf # include // MAXHOSTNAMELEN on Linux and the BSDs. -# include #endif // __POSIX__ // Add Windows fallback. @@ -84,21 +83,16 @@ static void GetHostname(const FunctionCallbackInfo& args) { static void GetOSType(const FunctionCallbackInfo& 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(); } - rval = info.sysname; -#else // __MINGW32__ - rval = "Windows_NT"; -#endif // __POSIX__ - args.GetReturnValue().Set(OneByteString(env->isolate(), rval)); + args.GetReturnValue().Set(OneByteString(env->isolate(), info.sysname)); }