如何使用带有 -S 选项的 xterm?

How to use xterm with -S option?

我正在尝试 ,它主要依赖于启动 xterm 时的 -S 选项。

来自手册页

-Sccn

This option allows xterm to be used as an input and output channel for an existing program and is sometimes used in spe‐ cialized applications. The option value specifies the last few letters of the name of a pseudo-terminal to use in slave mode, plus the number of the inherited file descriptor. If the option contains a “/” character, that delimits the characters used for the pseudo-terminal name from the file descriptor. Otherwise, exactly two characters are used from the option for the pseudo-terminal name, the remainder is the file descriptor. Examples (the first two are equivalent since the descriptor follows the last “/”):

    -S/dev/pts/123/45
    -S123/45
    -Sab34

Note that xterm does not close any file descriptor which it did not open for its own use. It is possible (though probably not portable) to have an application which passes an open file descriptor down to xterm past the initialization or the -S option to a process running in the xterm.

希望这个选项是利用xterm的输入输出通道,可以自定义。

如何使用这个选项?

"How to use" 范围很广。有几个使用示例:Tcl/Tk 脚本 multixterm written a while back, and the ditto program which is part of ncurses-examples.

这里提到后者:

  • Get output from Ncurses app on a separate terminal(附截图)
  • Sending curses input to another terminal in C via a fifo
  • Multiple xterm pseudoterminals used as output only from multiple threads

该选项用得不多;几年前出现了一些问题,已在 patch #314 中修复(较新的版本应该如图所示工作)。