On 28/May/2014 at 21:51:42 +0200, Jochen Bern wrote:
On 29.05.2014 00:58, reg14@rambler.ru wrote:
It seems that it tries to create pidfile in /var/run, and ignores that the file is already exists. As a result, pid is not written to stunnel.pid, and daemon crashes. Could this be fixed?
You might want to note that PID files are *supposed* to *not* exist if the software in question is not currently running. Try creating a *subdirectory* that the user has sufficient rights for, and have stunnel put the PID file there.
I did this way and discovered that stunnel does not remove pidfile on stopping if it has received SIGHUP during its session. PID does not change, stop is successful, but pidfile is not removed. Then it becomes impossible to determine whether stunnel is running or not. So reloading configuration makes a mess. I think that truncating pidfile in an init.d script is more reliable sign that service is stoped as compared with deleting pidfile. init.d sctipts are probably the more appropriate place to manipulate pidfile. All that a daemon should do is to create pidfile if it does not exist.