From 2f8b8d4c7c26b1c7e58c3d7b75e089cd8d152c22 Mon Sep 17 00:00:00 2001 From: Fabio Massaioli Date: Tue, 18 Oct 2016 15:56:49 +0200 Subject: [PATCH] Avoid exception in isService on Windows --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index bd7a565..0926783 100644 --- a/index.js +++ b/index.js @@ -50,6 +50,13 @@ exports.createServer = function (responder, authorizer, filter, config) { return new server.Server(responder, authorizer, filter, config); }; -exports.isService = function () { - return fs.fstatSync(0).isSocket(); +if (process.platform === "win32") { + exports.isService = function () { + return false; // On windows we need to call GetStdHandle(-10) + // from kernel32.dll + } +} else { + exports.isService = function () { + return fs.fstatSync(0).isSocket(); + } }