镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
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
16 changes: 5 additions & 11 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
# include <netdb.h> // MAXHOSTNAMELEN on Solaris.
# include <unistd.h> // gethostname, sysconf
# include <sys/param.h> // MAXHOSTNAMELEN on Linux and the BSDs.
# include <sys/utsname.h>
#endif // __POSIX__

// Add Windows fallback.
Expand Down Expand Up @@ -84,21 +83,16 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {

static void GetOSType(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();
}
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));
}


Expand Down