mod_tls: Update for new server SSL syntax
[prosody.git] / plugins / mod_posix.lua
index 2a724fb753b2b490c55bbe824b8f76dae79fba89..55d52ccda1e09419a2d92b88e391b421de463562 100644 (file)
@@ -7,7 +7,7 @@
 --
 
 
-local want_pposix_version = "0.3.2";
+local want_pposix_version = "0.3.3";
 
 local pposix = assert(require "util.pposix");
 if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version); end
@@ -20,6 +20,7 @@ end
 local logger_set = require "util.logger".setwriter;
 
 local lfs = require "lfs";
+local stat = lfs.attributes;
 
 local prosody = _G.prosody;
 
@@ -81,7 +82,8 @@ local function write_pidfile()
        end
        pidfile = module:get_option("pidfile");
        if pidfile then
-               pidfile_handle, err = io.open(pidfile, "a+");
+               local mode = stat(pidfile) and "r+" or "w+";
+               pidfile_handle, err = io.open(pidfile, mode);
                if not pidfile_handle then
                        module:log("error", "Couldn't write pidfile at %s; %s", pidfile, err);
                        prosody.shutdown("Couldn't write pidfile");