# LibTmux\Wait-TmuxChannel

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/WaitTmuxChannelCommand.cs#L7
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-wait-tmuxchannel/

```
Wait-TmuxChannel
    [-Server] <LibTmux.Server>
    [-Channel] <System.String>
    [-Timeout <System.Double>]
    [<CommonParameters>]
```

[`Wait`](/en/csharp/latest/reference/libtmux-tmuxwaitmode-wait/) for a tmux channel signal with a timeout and owned withdrawal.

[`Wait`](/en/csharp/latest/reference/libtmux-tmuxwaitmode-wait/) on the supplied native server and emit True after observing a channel
signal. A pending signal from before the call also completes the wait. An
empty owner pipeline performs no work and emits no output.

Use one open waiter per channel and give each operation a unique channel.
tmux has no individual waiter deregistration: withdrawing signals the channel
and wakes every waiter registered there. This command owns and disposes its
wait, including on timeout or pipeline cancellation, so an abandoned client
cannot consume a later signal. The borrowed server remains running.

The timeout bounds the wait attempt. Withdrawal is awaited before returning;
cleanup time is additional. A signal racing withdrawal can leave the channel
pending for a later caller. Do not infer that no signal arrived from a timeout,
and do not reuse a channel to identify a different operation.

### Notes

[`Tmux.ChannelWaitFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Wait-TmuxChannel.md#notes) retains the native server as its target. Timeout uses
TimeoutException with the OperationTimeout category and emits no success
object. [`ErrorAction`](/en/powershell/latest/reference/libtmux-wait-tmuxchannel/#LibTmux%5CWait-TmuxChannel.parameter.ErrorAction) Continue permits later owners to run; [`ErrorAction`](/en/powershell/latest/reference/libtmux-wait-tmuxchannel/#LibTmux%5CWait-TmuxChannel.parameter.ErrorAction) Stop
terminates on failure. Ctrl+C cancels the attempt and withdraws the waiter
before the pipeline stops. Cancellation cannot undo work in the producer.
Invalid channels and timeouts fail before contacting tmux.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Server`: The native server to wait on.
- **Outputs:** `System.Boolean`

Related APIs:

- [Send input and wait for completion](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/input.md)

## Examples

Example 1

Use a previously selected native $server and reserve build-finished for one
waiter. Have the producer run tmux wait-for -S build-finished on that server
after its work completes. The producer may signal before this command starts.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Wait-TmuxChannel.md).

```powershell
$server | LibTmux\Wait-TmuxChannel -Channel 'build-finished' -Timeout 10
```

## Parameters

- `Server` (`LibTmux.Server`): The native server endpoint that owns the channel.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Channel` (`System.String`): The nonempty, non-whitespace channel reserved for this operation. NUL is rejected.
  Required. Position 1. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `Timeout` (`System.Double`): The wait budget in seconds. Fractions are accepted. The default is 10; the
valid range is 0.0000001 through 86400. NaN and infinity are rejected.
  Optional. Named parameter. Does not accept pipeline input. Documented default: `10`.
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.

## Returns

`System.Boolean`: True after observing a signal. Timeout emits an error, not False.
