aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-11-11 23:48:38 +0100
committerKim Alvefur <zash@zash.se>2012-11-11 23:48:38 +0100
commit20b97c9c9372fd03f9665669399065869eec0bce (patch)
tree6367ad48930ec474c7797b1f53089e0e52c684a2
parent326bb884c8bce004961b32f00485f52c216bf5d4 (diff)
parent8f3a73f5c58b6e2ef954fc61f8ae84ae71d1ff86 (diff)
downloadprosody-20b97c9c9372fd03f9665669399065869eec0bce.tar.gz
prosody-20b97c9c9372fd03f9665669399065869eec0bce.zip
Merge 0.9 -> trunk
-rw-r--r--plugins/mod_posix.lua9
-rw-r--r--util-src/pposix.c4
2 files changed, 13 insertions, 0 deletions
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index db594ccc..e871e5cf 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -136,8 +136,17 @@ if daemonize == nil then
end
end
+local function remove_log_sinks()
+ local lm = require "core.loggingmanager";
+ lm.register_sink_type("console", nil);
+ lm.register_sink_type("stdout", nil);
+ lm.reload_logging();
+end
+
if daemonize then
local function daemonize_server()
+ module:log("info", "Prosody is about to detach from the console, disabling further console output");
+ remove_log_sinks();
local ok, ret = pposix.daemonize();
if not ok then
module:log("error", "Failed to daemonize: %s", ret);
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 191e276e..05303d99 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -89,6 +89,10 @@ static int lc_daemonize(lua_State *L)
close(0);
close(1);
close(2);
+ /* Make sure accidental use of FDs 0, 1, 2 don't cause weirdness */
+ open("/dev/null", O_RDONLY);
+ open("/dev/null", O_WRONLY);
+ open("/dev/null", O_WRONLY);
/* Final fork, use it wisely */
if(fork())