# LibTmux.run_command

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

```
run_command(
    connection::LibTmux.ControlConnection,
    argv::AbstractString...;
    timeout,
    cancel,
    check
)

run_command(server::LibTmux.Server, args::AbstractString...; check, env, kwargs...)
```

## Methods

### `run_command` (overload 1)

```julia
run_command(
    connection::LibTmux.ControlConnection,
    argv::AbstractString...;
    timeout,
    cancel,
    check
)
```

[Source](https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/control.jl#L572).

Run an admitted command on the existing control connection. The initial allowlist covers exact-ID destruction and restricted-name buffer deletion; raw output producers, formats and borrowed wait channels are rejected. Cancellation before write admission sends nothing. After admission it reports uncertain effects; its ledger slot remains until the completion fence retires. No command is replayed and no other transport is selected.

```julia
run_command(connection::ControlConnection, argv...; timeout=5.0, cancel=nothing, check=true)
```

### `run_command(server::LibTmux.Server, args::AbstractString...; check, env, kwargs...)`

[Source](https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/src/process.jl#L477).

Run one tmux client with literal arguments and return owned output bytes. The client uses UTF-8 mode independently of the caller's locale. Nonzero exits raise `CommandError` unless `check=false`. I/O yields to other Julia tasks. Cancellation kills and reaps the client, not any remote pane job. This subprocess path checks no server generation; use strict references only through transports that explicitly advertise that capability.

```julia
run_command(server, args...; check=true, env=ENV, input=UInt8[], cancel=nothing,
            timeout=nothing, max_output_bytes=8388608, max_error_bytes=1048576)
```



The first cancellation, deadline, output overflow or pipe error wins. Its `result` retains bounded output and observed exit/signal evidence after client retirement; it is `nothing` before submission. Failed input delivery is an I/O error even with `check=false`. Cleanup allows at most 900 ms for inherited output pipes after stopping the owned client, then closes them. Return or failure joins I/O tasks, timer tasks and any running cancellation callback. If cleanup also fails, `CompositeException` preserves the primary error first.

Arguments and individual environment entries are limited to a conservative 14 KiB; the combined client environment is limited to 128 KiB. Oversized entries fail before submission instead of being silently omitted by tmux. Inherited `TMUX` and `TMUX_PANE` are always removed.

## Parameters

- `connection` (`LibTmux.ControlConnection`) (for `run_command(connection, argv, timeout, cancel, check)`)
- `argv` (`Vararg{AbstractString}`) (for `run_command(connection, argv, timeout, cancel, check)`)
- `timeout` (`Real`) (for `run_command(connection, argv, timeout, cancel, check)`)
  Default: `5.0`.
- `cancel` (for `run_command(connection, argv, timeout, cancel, check)`)
  Default: `nothing`.
- `check` (`Bool`)
  Default: `true`.
- `server` (`LibTmux.Server`) (for `run_command(server, args, check, env, kwargs)`)
- `args` (`Vararg{AbstractString}`) (for `run_command(server, args, check, env, kwargs)`)
- `env` (`AbstractDict`) (for `run_command(server, args, check, env, kwargs)`)
  Default: `ENV`.
- `kwargs` (for `run_command(server, args, check, env, kwargs)`)
