diff --git a/src/node.cc b/src/node.cc index be596304d4..5357f1fcb2 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1081,6 +1081,9 @@ static Handle Cwd(const Arguments& args) { return scope.Close(cwd); } + +#ifdef __POSIX__ + static Handle Umask(const Arguments& args){ HandleScope scope; unsigned int old; @@ -1184,6 +1187,8 @@ static Handle SetUid(const Arguments& args) { return Undefined(); } +#endif // __POSIX__ + v8::Handle Exit(const v8::Arguments& args) { HandleScope scope; @@ -1252,6 +1257,7 @@ v8::Handle MemoryUsage(const v8::Arguments& args) { return scope.Close(info); } +#ifdef __POSIX__ Handle Kill(const Arguments& args) { HandleScope scope; @@ -1349,6 +1355,8 @@ Handle DLOpen(const v8::Arguments& args) { return Undefined(); } +#endif // __POSIX__ + // TODO remove me before 0.4 Handle Compile(const Arguments& args) { @@ -1573,7 +1581,11 @@ static Handle EnvSetter(Local property, const AccessorInfo& info) { String::Utf8Value key(property); String::Utf8Value val(value); +#ifdef __POSIX__ setenv(*key, *val, 1); +#else // __WIN32__ + NO_IMPL_MSG(setenv) +#endif return value; } @@ -1593,7 +1605,11 @@ static Handle EnvDeleter(Local property, const AccessorInfo& info) { String::Utf8Value key(property); if (getenv(*key)) { +#ifdef __POSIX__ unsetenv(*key); // prototyped as `void unsetenv(const char*)` on some platforms +#else + NO_IMPL_MSG(unsetenv) +#endif return True(); } return False(); @@ -1711,6 +1727,8 @@ static void Load(int argc, char *argv[]) { NODE_SET_METHOD(process, "reallyExit", Exit); NODE_SET_METHOD(process, "chdir", Chdir); NODE_SET_METHOD(process, "cwd", Cwd); + +#ifdef __POSIX__ NODE_SET_METHOD(process, "getuid", GetUid); NODE_SET_METHOD(process, "setuid", SetUid); @@ -1720,6 +1738,8 @@ static void Load(int argc, char *argv[]) { NODE_SET_METHOD(process, "umask", Umask); NODE_SET_METHOD(process, "dlopen", DLOpen); NODE_SET_METHOD(process, "_kill", Kill); +#endif // __POSIX__ + NODE_SET_METHOD(process, "memoryUsage", MemoryUsage); NODE_SET_METHOD(process, "binding", Binding); @@ -1873,7 +1893,7 @@ static void SignalExit(int signal) { _exit(1); } - +#ifdef __POSIX__ static int RegisterSignalHandler(int signal, void (*handler)(int)) { struct sigaction sa; @@ -1882,6 +1902,7 @@ static int RegisterSignalHandler(int signal, void (*handler)(int)) { sigfillset(&sa.sa_mask); return sigaction(signal, &sa, NULL); } +#endif // __POSIX__ int Start(int argc, char *argv[]) { @@ -1921,10 +1942,12 @@ int Start(int argc, char *argv[]) { } V8::SetFlagsFromCommandLine(&v8argc, v8argv, false); +#ifdef __POSIX__ // Ignore SIGPIPE RegisterSignalHandler(SIGPIPE, SIG_IGN); RegisterSignalHandler(SIGINT, SignalExit); RegisterSignalHandler(SIGTERM, SignalExit); +#endif // __POSIX__ #ifdef __MINGW32__ // On windows, to use winsock it must be initialized