diff --git a/cmd/wsl2-ssh-agent-proxy/main.go b/cmd/wsl2-ssh-agent-proxy/main.go index 76bfacf..a5956fd 100644 --- a/cmd/wsl2-ssh-agent-proxy/main.go +++ b/cmd/wsl2-ssh-agent-proxy/main.go @@ -312,21 +312,18 @@ func main() { ps := NewPwshIOStream(exePath) defer ps.killPwsh() go ps.sigStopWorker() + listener, err := net.Listen("unix", socketPath) + if err != nil { + log.Println("Error creating Unix domain socket:", err) + return + } + defer listener.Close() for { // Start PowerShell process ctx, cancel := context.WithCancel(context.Background()) ps.setCancel(cancel) go ps.startPowerShellProces(ctx) - - // Handle kill signals - log.Printf("listen socket:%s", socketPath) - listener, err := net.Listen("unix", socketPath) - if err != nil { - log.Println("Error creating Unix domain socket:", err) - return - } - defer listener.Close() ps.listenLoop(ctx, listener) cancel() }