What does the “first pid of a pane” in tmux mean

tmux

The entry in the tmux manpage's list of available variables for pane_pid reads as follows:

pane_pid PID of first process in pane

However, according to Run or send a command to a tmux pane in a running tmux session, "tmux does not supply a way to add extra processes to a pane once it has been started with its initial command."

So… what does it mean to return the PID of the first process of a pane? Is it reasonable to assume that this is the one and only PID of the pane, or is there actually some way for a pane to have multiple associated PIDs?

Best Answer

The PID returned by pane_pid is generally the PID of the command specified when opening the window (or the shell that was opened when no command was specified).

However, it is important to note that when specifying commands like top; bash -i, tmux prefixes the command with bash -c (i.e. the actual command executed when creating the pane is bash -c top; bash -i). In this case, the PID is that of the bash -c process, not of top.

In a sense, then, the "first process" of a pane is the one and only process of a pane, but it is not necessarily the process associated directly with the specified command.

Related Question