From bf70f4dc080847d05bf960d40aae45b442da8b96 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Thu, 6 Nov 2025 17:18:26 +0900 Subject: [PATCH 1/2] pkg/networks/usernet: Use `SIGINT` instead of `SIGKILL` By this change, `limactl usernet` can stop gracefully. Signed-off-by: Norio Nomura --- pkg/networks/usernet/recoincile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/networks/usernet/recoincile.go b/pkg/networks/usernet/recoincile.go index c1329b7c1c1..350517742f1 100644 --- a/pkg/networks/usernet/recoincile.go +++ b/pkg/networks/usernet/recoincile.go @@ -143,7 +143,7 @@ func Stop(ctx context.Context, name string) error { return err } - if err := osutil.SysKill(pid, osutil.SigKill); err != nil { + if err := osutil.SysKill(pid, osutil.SigInt); err != nil { logrus.Error(err) return fmt.Errorf("failed to kill process with pid %d: %w", pid, err) } From a392c0d83fe93174a246e13fc3920355a0a613bd Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Thu, 6 Nov 2025 17:48:01 +0900 Subject: [PATCH 2/2] pkg/networks/usernet: Add fallback to `SIGKILL` Signed-off-by: Norio Nomura --- pkg/networks/usernet/recoincile.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/networks/usernet/recoincile.go b/pkg/networks/usernet/recoincile.go index 350517742f1..ebc477ceaa6 100644 --- a/pkg/networks/usernet/recoincile.go +++ b/pkg/networks/usernet/recoincile.go @@ -157,7 +157,10 @@ func Stop(ctx context.Context, name string) error { break } if time.Since(startWaiting) > 5*time.Second { - logrus.Infof("usernet network still running after 5 seconds") + logrus.Infof("usernet network still running after 5 seconds. Attempting to forcibly kill") + if err := osutil.SysKill(pid, osutil.SigKill); err != nil { + logrus.Error(err) + } break } time.Sleep(500 * time.Millisecond)