{"record":{"id":"df071265e4cead50","repo":"abiosoft/colima","slug":"error-checking-vmnet-process-w","errorCode":null,"errorMessage":"error checking vmnet process: %w","messagePattern":"error checking vmnet process: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/process/vmnet/vmnet.go","lineNumber":49,"sourceCode":"\t\tmode:         mode,\n\t\tnetInterface: netInterface,\n\t}\n}\n\ntype vmnetProcess struct {\n\tmode         string\n\tnetInterface string\n}\n\nfunc (*vmnetProcess) Alive(ctx context.Context) error {\n\tinfo := Info()\n\tpidFile := info.PidFile\n\tsocketFile := info.Socket.File()\n\n\tif _, err := os.Stat(pidFile); err == nil {\n\t\tcmd := exec.CommandContext(ctx, \"sudo\", \"/usr/bin/pkill\", \"-0\", \"-F\", pidFile)\n\t\tif err := cmd.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"error checking vmnet process: %w\", err)\n\t\t}\n\t}\n\n\tif _, err := os.Stat(socketFile); err != nil {\n\t\treturn fmt.Errorf(\"vmnet socket file not found error: %w\", err)\n\t}\n\tif n, err := net.Dial(\"unix\", socketFile); err != nil {\n\t\treturn fmt.Errorf(\"vmnet socket file error: %w\", err)\n\t} else {\n\t\tif err := n.Close(); err != nil {\n\t\t\tlogrus.Debugln(fmt.Errorf(\"error closing ping socket connection: %w\", err))\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Name implements process.BgProcess","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/daemon/process/vmnet/vmnet.go#L31-L67","documentation":"Thrown by vmnetProcess.Alive() while Colima's daemon checks whether the rootful socket_vmnet process is healthy. If the pidfile exists, it runs `sudo /usr/bin/pkill -0 -F <pidfile>` (signal 0 = existence check only); a non-zero exit means the recorded process is dead, the pid was recycled, sudo failed, or pkill could not read the pidfile — all wrapped into this error.","triggerScenarios":"The vmnet pidfile exists at /opt/colima/run/vmnet-<profile>.pid but the process is gone (crashed, was killed, machine rebooted); pidfile is stale and the pid now belongs to another process; sudo prompt cancelled during the check; /usr/bin/pkill missing (non-macOS, tampered system).","commonSituations":"socket_vmnet daemon crashed after a macOS update or sleep/wake cycle; leftover pidfile from an unclean `colima stop -f` or host reboot; user manually pkill'ed socket_vmnet; running colima on a host where /usr/bin/pkill path differs.","solutions":["Restart cleanly: `colima stop --vz-rosetta` no — use `colima stop` then `colima start` so the daemon re-spawns vmnet and rewrites the pidfile","Remove the stale pidfile: `sudo rm /opt/colima/run/vmnet-<profile>.pid` (check `pgrep -l socket_vmnet` first)","If socket_vmnet keeps dying, capture logs: run colima with `--verbose` (sets DEBUG=1 for the daemon) and inspect output","Reinstall the vmnet binaries if corrupted: `sudo rm -rf /opt/colima` then start again","Escalate to the colima GitHub issues if the crash reproduces deterministically"],"exampleFix":"# before: stale pidfile makes Alive() fail\ncolima status   # reports vmnet down\n# after\npgrep -l socket_vmnet || sudo rm -f /opt/colima/run/vmnet-*.pid\ncolima stop && colima start","handlingStrategy":"validation","validationCode":"// Cheap liveness check without sudo/pkill\nfunc vmnetLooksAlive(pidFile string) bool {\n    b, err := os.ReadFile(pidFile)\n    if err != nil {\n        return false // no pidfile: Alive() skips the pkill check anyway\n    }\n    pid, err := strconv.Atoi(strings.TrimSpace(string(b)))\n    if err != nil {\n        return false // malformed pidfile will break pkill -F\n    }\n    p, err := os.FindProcess(pid)\n    return err == nil && p != nil && p.Signal(syscall.Signal(0)) == nil\n}","typeGuard":null,"tryCatchPattern":"if err := vmnet.Alive(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error checking vmnet process\") {\n        // pidfile exists but process is dead or sudo failed — treat as not-alive\n        log.Debug(\"vmnet process check failed; assuming dead: \", err)\n        _ = os.Remove(stalePidFileCleanup()) // after confirming process absence\n    }\n    // other Alive errors (socket) mean daemon needs restart\n    return restartVmnetDaemon(ctx)\n}","preventionTips":["Always stop colima cleanly (colima stop) so pidfiles are removed","After host reboots/sleep, expect stale pidfiles: clean /opt/colima/run/*.pid before diagnosing","Don't manually kill socket_vmnet without removing its pidfile","Ensure /usr/bin/pkill exists (macOS standard) when running on unusual setups"],"tags":["colima","vmnet","pidfile","process-check","macos","daemon"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}