Fix: controlled interrupt exit for subprograms

- Openvpn and Unbound do not receive OS signals
- Openvpn and Unbound run in a different process group than the entrypoint
- Openvpn and Unbound are gracefully shutdown by the entrypoint
- Update golibs with a modified command package
- Update dns to v1.9.0 where Unbound is luanched in its own group
This commit is contained in:
Quentin McGaw (desktop)
2021-07-16 20:04:17 +00:00
parent c2d527bbd3
commit 7c44188130
5 changed files with 24 additions and 11 deletions

View File

@@ -4,7 +4,9 @@ import (
"context"
"errors"
"fmt"
"os/exec"
"strings"
"syscall"
"github.com/qdm12/gluetun/internal/constants"
)
@@ -30,7 +32,10 @@ func (c *configurator) Start(ctx context.Context, version string) (
c.logger.Info("starting OpenVPN " + version)
return c.commander.Start(ctx, bin, "--config", constants.OpenVPNConf)
cmd := exec.CommandContext(ctx, bin, "--config", constants.OpenVPNConf)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
return c.commander.Start(cmd)
}
func (c *configurator) Version24(ctx context.Context) (version string, err error) {
@@ -44,7 +49,8 @@ func (c *configurator) Version25(ctx context.Context) (version string, err error
var ErrVersionTooShort = errors.New("version output is too short")
func (c *configurator) version(ctx context.Context, binName string) (version string, err error) {
output, err := c.commander.Run(ctx, binName, "--version")
cmd := exec.CommandContext(ctx, binName, "--version")
output, err := c.commander.Run(cmd)
if err != nil && err.Error() != "exit status 1" {
return "", err
}