Stunnel should remove it on abnormal exit. It's customary. See here http://stackoverflow.com/questions/688343/reference-for-proper-handling-of-pid-file-on-unix

On May 28, 2014 5:48 PM, <reg14@rambler.ru> wrote:
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.
_______________________________________________
stunnel-users mailing list
stunnel-users@stunnel.org
https://www.stunnel.org/cgi-bin/mailman/listinfo/stunnel-users