# LibTmux.on_cancel

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** Julia
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/process.jl#L157
- **Page:** https://libtmux.org/en/julia/latest/reference/libtmux-on_cancel/

```
on_cancel(f, token::LibTmux.CancellationToken)
```

## Methods

Register a callable and return a `CancellationSubscription`. `cancel!` invokes each registered callback once, outside the token lock, on its calling task. If already cancelled, invoke `f()` before returning. Keep callbacks prompt: signal an event or stop an owned process; do not wait for operation completion. Callback failures are collected after all callbacks run and raised together.

```julia
on_cancel(f, token::CancellationToken)
```



Closing a subscription prevents later invocation and joins a callback already running on another task. Close subscriptions when their operation retires.

## Parameters

- `f` (`Any`)
- `token` (`LibTmux.CancellationToken`)
