{"record":{"id":"1b5cfcb9f33d75ec","repo":"abiosoft/colima","slug":"error-sending-sigterm-to-daemon-w","errorCode":null,"errorMessage":"error sending sigterm to daemon: %w","messagePattern":"error sending sigterm to daemon: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/daemon/daemon.go","lineNumber":92,"sourceCode":"\t\t}\n\t}\n\n\tctx, stop := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)\n\tdefer stop()\n\n\treturn RunProcesses(ctx, processes...)\n}\n\nfunc stop(ctx context.Context) error {\n\tif status() != nil {\n\t\t// not running\n\t\treturn nil\n\t}\n\n\tinfo := Info()\n\n\tif err := cli.CommandInteractive(\"/usr/bin/pkill\", \"-F\", info.PidFile).Run(); err != nil {\n\t\treturn fmt.Errorf(\"error sending sigterm to daemon: %w\", err)\n\t}\n\n\tlogrus.Info(\"waiting for process to terminate\")\n\n\tfor {\n\t\talive := status() == nil\n\t\tif !alive {\n\t\t\treturn nil\n\t\t}\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tdefault:\n\t\t\ttime.Sleep(time.Second * 1)\n\t\t}\n\t}\n\n}","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/daemon/daemon.go#L74-L110","documentation":"Returned by stop (cmd/daemon/daemon.go:92) when the hardcoded `/usr/bin/pkill -F <pidfile>` fails while trying to SIGTERM the daemon. The %w carries the pkill exit error.","triggerScenarios":"The daemon process died between the status() check and pkill running (pid vanished); /usr/bin/pkill does not exist at that path (non-macOS or altered systems — the path is hardcoded); insufficient permission to signal the daemon (daemon owned by another user).","commonSituations":"`colima daemon stop` racing a crashing daemon; running on Linux distros where pkill lives outside /usr/bin; daemon started under sudo.","solutions":["Retry the stop command — if the daemon already exited, status() now reports not-running and stop returns nil","Verify the binary path exists: `ls -l /usr/bin/pkill`; on systems where it differs, signal manually: `kill -TERM $(cat <pidfile>)`","If the pid is stale, confirm with `ps -p $(cat <pidfile>)` and remove the pid file","Ensure you stop the daemon as the same user that started it"],"exampleFix":"# before\ncolima daemon stop   # error sending sigterm to daemon: exit status 1\n\n# after\nps -p $(cat ~/.colima/daemon/daemon.pid) || rm ~/.colima/daemon/daemon.pid  # clear stale pid\nkill -TERM $(cat ~/.colima/daemon/daemon.pid) 2>/dev/null; colima daemon stop","handlingStrategy":"retry","validationCode":"// Soften the race: check the pid is alive right before signaling\nif p, err := os.ReadFile(pidFile); err == nil {\n    if pid, _ := strconv.Atoi(string(p)); pid != 0 {\n        if proc, err := os.FindProcess(pid); err == nil {\n            _ = proc.Signal(syscall.Signal(0)) // alive check; ignore result\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := daemonStop(); err != nil {\n    if strings.Contains(err.Error(), \"error sending sigterm\") {\n        // usually a race: the daemon already died. Re-check status once.\n        if daemonStatus() != nil {\n            return nil // not running — mission accomplished\n        }\n    }\n    return err\n}","preventionTips":["Treat stop as idempotent — re-running after this error usually resolves it","On non-macOS systems, signal the daemon directly via kill -TERM $(cat <pidfile>) since /usr/bin/pkill is hardcoded","Stop the daemon as the same user that started it"],"tags":["daemon","signals","process","stop","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}