Skip to contentSkip to conversation

PID is deleted unconditionally on exit

Openvpn-devel Matthias May 3 participants 3 messages May 12, 2021 – Jun 15, 2021

lore
Share & tools
lore
#0 lore raw

Hi Gert

We recently updated OpenVPN to 2.5.2 and found that the PID
is since [1] unconditionally deleted when OpenVPN exits.
This breaks OpenVPN in our init.
We relied on this file to get the PID to be able to check if the process actually started, or something went wrong during init, or to see if the process died sometime later.

One could argue that the absence of the PID file is indication enough that the process doesn't exist anymore, but that doesn't hold up when there are multiple instances running.

Once the process died we used the PID to look in the syslog for clues as to why the process died, and present the user with an error message based on that.

Can you please revert this unconditional deletion of the file? Or do you see any alternative to get the PID of a process that exits immediately (case of misconfiguration)?

BR
Matthias

[1] https://sourceforge.net/p/openvpn/mailman/message/37055147/

#1 lore raw

Hi,

this also got no answer so far, but deserves one.

Quoted 2 lines · Matthias May via Openvpn-devel

We recently updated OpenVPN to 2.5.2 and found that the PID is since [1] unconditionally deleted when OpenVPN exits.

Right.

Quoted 1 line

This breaks OpenVPN in our init.

Sorry for that.

Quoted 4 lines

We relied on this file to get the PID to be able to check if the process actually started, or something went wrong during init, or to see if the process died sometime later.

One could argue that the absence of the PID file is indication enough that the process doesn't exist anymore, but that doesn't hold up when there are multiple instances running.

I do argue that way, and the "multiple instances running" argument does not convince me - if you have multiple instances, they must have unique PID files anyway, so you can see if "openvpn_instance4.pid" exists or not.

So, at startup, you can have 3 situations

- openvpn started normally, PID exists, process exists
- openvpn exited (planned or error exit), PID does not exist
- openvpn crashed (core dump-style), PID exists, process does not exist

this is fairly easy to figure out whether a given instance started up fine.

Quoted 6 lines

Once the process died we used the PID to look in the syslog for clues as to why the process died, and present the user with an error message based on that.

Can you please revert this unconditional deletion of the file? Or do you see any alternative to get the PID of a process that exits immediately (case of misconfiguration)?

This depends on how you start these instances - if you start them without --daemon, and call wait() in the caller, you get the PID of whoever exited back. If you use systemd, with named instances, it will tell you in the journal (by instance named).

To find a certain instance in syslog (if you have no systemd), you can also use the "--syslog instance1234" trick - so each instance would send its own identifier, and you can look for "instance1234[" in syslog.

But generally speaking, a process that is ending normally (and we consider "error exit" to be "ending normally", as opposed to "SIGSEGV core dump boom") should not end with any resources still in use - so, tun interface and routes are cleaned up, pid file is removed, auth_control_files are removed, etc. - and we really believe in "cleaning up". OpenVPN did not always do the right thing (especially cleaning up interfaces on error exit), but we're getting there.

Again, sorry that we caused work here.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#2 lore raw
In reply to Matthias May
Quoted 5 lines · Matthias May via Openvpn-devel

Hi Gert

We recently updated OpenVPN to 2.5.2 and found that the PID is since [1] unconditionally deleted when OpenVPN exits. This breaks OpenVPN in our init.

What kind of init system is this? On what kind of distribution?

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc