abiosoft/colima · error

error sending sigterm to daemon: %w

Error message

error sending sigterm to daemon: %w

What it means

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.

Source

Thrown at cmd/daemon/daemon.go:92

		}
	}

	ctx, stop := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)
	defer stop()

	return RunProcesses(ctx, processes...)
}

func stop(ctx context.Context) error {
	if status() != nil {
		// not running
		return nil
	}

	info := Info()

	if err := cli.CommandInteractive("/usr/bin/pkill", "-F", info.PidFile).Run(); err != nil {
		return fmt.Errorf("error sending sigterm to daemon: %w", err)
	}

	logrus.Info("waiting for process to terminate")

	for {
		alive := status() == nil
		if !alive {
			return nil
		}
		select {
		case <-ctx.Done():
			return ctx.Err()
		default:
			time.Sleep(time.Second * 1)
		}
	}

}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Retry the stop command — if the daemon already exited, status() now reports not-running and stop returns nil
  2. Verify the binary path exists: `ls -l /usr/bin/pkill`; on systems where it differs, signal manually: `kill -TERM $(cat <pidfile>)`
  3. If the pid is stale, confirm with `ps -p $(cat <pidfile>)` and remove the pid file
  4. Ensure you stop the daemon as the same user that started it

Example fix

# before
colima daemon stop   # error sending sigterm to daemon: exit status 1

# after
ps -p $(cat ~/.colima/daemon/daemon.pid) || rm ~/.colima/daemon/daemon.pid  # clear stale pid
kill -TERM $(cat ~/.colima/daemon/daemon.pid) 2>/dev/null; colima daemon stop
Defensive patterns

Strategy: retry

Validate before calling

// Soften the race: check the pid is alive right before signaling
if p, err := os.ReadFile(pidFile); err == nil {
    if pid, _ := strconv.Atoi(string(p)); pid != 0 {
        if proc, err := os.FindProcess(pid); err == nil {
            _ = proc.Signal(syscall.Signal(0)) // alive check; ignore result
        }
    }
}

Try / catch

if err := daemonStop(); err != nil {
    if strings.Contains(err.Error(), "error sending sigterm") {
        // usually a race: the daemon already died. Re-check status once.
        if daemonStatus() != nil {
            return nil // not running — mission accomplished
        }
    }
    return err
}

Prevention

When it happens

Trigger: 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).

Common situations: `colima daemon stop` racing a crashing daemon; running on Linux distros where pkill lives outside /usr/bin; daemon started under sudo.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/1b5cfcb9f33d75ec. Report an issue: GitHub.