Skip to content

canair lock

usage: canair lock [-h] [--json] ACTION ...

``canair lock`` — inspect and clear the device connection mutex.

Only one canair session may talk to the device at a time. Normally the mutex
looks after itself: it is released when the holder exits, and a live holder
stands down when another run asks for the connection with ``--force``.

This command is for the case where you need to look at — or clear — the mutex
without starting a session:

- ``canair lock`` shows who holds it (PID, command line, how long).
- ``canair lock steal`` asks that session to release the connection and waits,
  so the next command can run. Nothing is signalled or killed.
- ``canair lock kill`` signals the holder, for a session too old (or too wedged)
  to release cooperatively. Confirmed first, and only ever aimed at a live
  canair process.

positional arguments:
  ACTION
    steal     Ask the current session to release the connection, then wait
    kill      Signal a holder that won't release the connection cooperatively

options:
  -h, --help  show this help message and exit
  --json      Emit machine-readable JSON

examples:
  canair lock                  # who holds the device connection?
  canair lock --json           # machine-readable
  canair lock steal            # ask the holder to release it, then wait
  canair lock steal --wait 30  # allow a slower teardown
  canair lock kill             # signal a holder that won't release (confirms)
  canair lock kill --hard -y   # SIGKILL it, no prompt (data is in the journal)

exit codes: 0 = lock is free (or was freed), 1 = still held.

canair lock steal

usage: canair lock steal [-h] [--wait SECONDS] [--yes] [--json]

Records a release request the holder's watchdog picks up, waits for it to let
go, and leaves the lock free. Never signals or kills anything.

options:
  -h, --help      show this help message and exit
  --wait SECONDS  How long to wait for the holder to release (default: 10)
  --yes, -y       Skip the confirmation
  --json          Emit machine-readable JSON

canair lock kill

usage: canair lock kill [-h] [--hard] [--yes] [--json]

Sends SIGTERM (a graceful stop: the session reconciles its --save journal on
the way out), or SIGKILL with --hard. Only ever aimed at a live canair
process.

options:
  -h, --help  show this help message and exit
  --hard      Send SIGKILL instead of SIGTERM (last resort)
  --yes, -y   Skip the confirmation
  --json      Emit machine-readable JSON