diff options
Diffstat (limited to 'internal/cli/cli.go')
| -rw-r--r-- | internal/cli/cli.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 4d028a2..4b3e36a 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -123,10 +123,12 @@ func (a *App) Run() error { } if namespace.IsIsolated() { + fmt.Printf("DEBUG: IsIsolated=true, RuntimeBaseDir=%s\n", a.getPathManager().RuntimeBaseDir()) return a.ExecuteCommand(cfg) } pm := a.getPathManager() + fmt.Printf("DEBUG: IsIsolated=false, RuntimeBaseDir=%s\n", pm.RuntimeBaseDir()) // Preserve the host runtime base dir in the environment before bootstrapping _ = os.Setenv("WG_WRAP_HOST_RUNTIME_BASE_DIR", pm.RuntimeBaseDir()) @@ -143,6 +145,11 @@ func (a *App) Run() error { if err == nil && activePid > 0 { // Release the lock before executing the command to allow others to join namespace.ReleaseProfileLock(lockFile) + + // Register this PID before joining to prevent the race where the joining process + // hasn't registered itself yet, causing the existing process to think it's the last one. + _ = namespace.RegisterProcess(pm, cfg.Profile) + if err := namespace.BootstrapJoin(activePid); err != nil { return fmt.Errorf("failed to join existing namespace: %w", err) } @@ -265,7 +272,7 @@ func (a *App) ExecuteCommand(cfg *config.Config) error { } } - tunnel, err := wireguard.StartTunnel(wgCfg, dnsServer) + tunnel, err := wireguard.StartTunnel(pm, cfg.Profile, wgCfg, dnsServer) if err != nil { return fmt.Errorf("failed to start WireGuard tunnel: %w", err) } |
