DISPLAY环境变量的语法是什么?

时间:2019-10-15 01:08:58

标签: linux x11

我正在用Linux的x86-64汇编语言编写程序,该程序将仅使用通过 syscall 指令调用的系统调用来创建X11窗口。根据DISPLAY环境变量的内容,我必须创建tcp或unix套接字。在Linux手册“ man 7 X”中写道:

  

显示名称的主机名部分应为空字符串。例如:: 0,:1和:0.1。将选择最高效的本地交通工具。

但是,我从https://en.wikibooks.org/wiki/X_Window_Programming/XCB编译了C代码示例,并在GDB中使用已更改的DISPLAY环境变量运行了已编译的可执行文件。当我将DISPLAY环境变量从DISPLAY =:0更改为DISPLAY = unix:0或DISPLAY = unix /:0或DISPLAY = unix / abc:0时,仍会创建窗口。 linux manual错误吗?DISPLAY环境变量的真正语法是什么?

1 个答案:

答案 0 :(得分:0)

简短的回答:X11可以通过多种传输方式运行。该评论与“本地”连接有关。

长答案:

您包括的引用是指“本地”连接。 X11系统可以在几个tarnsport层上运行。在我的系统上:

       local
               The hostname part of the display name should be the empty string.  For example:  :0, :1, and :0.1.  The most effi‐
               cient local transport will be chosen.

       TCPIP
               The hostname part of the display name should be the server machine's hostname or IP address.  Full Internet names,
               abbreviated names, IPv4 addresses, and IPv6 addresses are all allowed.  For  example:  x.org:0,  expo:0,  [::1]:0,
               198.112.45.11:0, bigmachine:1, and hydra:0.1.

此外,许多系统都支持在unix套接字上运行,该套接字(至少在过去)比TCP连接更有效。