Comparison

util/prosodyctl.lua @ 2796:1e287badd033

prosodyctl: Use mode r+ for opening the file so 1) it fails if the file doesn't exist 2) we have write access to lock it
author Matthew Wild <mwild1@gmail.com>
date Wed, 13 Jan 2010 00:04:38 +0000
parent 2794:5f14cd94a563
child 2923:b7049746bd29
comparison
equal deleted inserted replaced
2795:d6fcd13c07e7 2796:1e287badd033
63 local pidfile = config.get("*", "core", "pidfile"); 63 local pidfile = config.get("*", "core", "pidfile");
64 if not pidfile then 64 if not pidfile then
65 return false, "no-pidfile"; 65 return false, "no-pidfile";
66 end 66 end
67 67
68 local file, err = io.open(pidfile, "w"); 68 local file, err = io.open(pidfile, "r+");
69 if not file then 69 if not file then
70 return false, "pidfile-read-failed", err; 70 return false, "pidfile-read-failed", err;
71 end 71 end
72 72
73 local locked, err = lfs.lock(file, "w"); 73 local locked, err = lfs.lock(file, "w");