diff --git a/rlgwebd.js b/rlgwebd.js index 1129af6..75c0bb6 100755 --- a/rlgwebd.js +++ b/rlgwebd.js @@ -992,7 +992,6 @@ function shutdown () { httpServer.close(); httpServer.removeAllListeners('request'); ctlServer.close(); - fs.unlink(ctlsocket); tslog("Shutting down..."); process.exit(); } @@ -1027,6 +1026,11 @@ if (process.getuid() != 0) { var httpServer; // declare here so shutdown() can find it +/* This could be nonblocking, but nothing else can start yet anyway. */ +if (fs.existsSync(ctlsocket)) { + fs.unlinkSync(ctlsocket); +} + /* Open the control socket before chrooting where it can't be found */ var ctlServer = net.createServer(function (sock) { sock.on('data', conHandler);