如果我使用 xtigervncviewer 尝试连接到不运行 VNC 服务器的主机,它会向 stderr 打印以下预期错误:
$ xtigervncviewer -AlertOnFatalError=0 localhost
TigerVNC Viewer 64-bit v1.9.0
Built on: 2020-01-23 18:03
Copyright (C) 1999-2018 TigerVNC Team and many others (see README.rst)
See http://www.tigervnc.org for information on TigerVNC.
Fri May 1 15:55:44 2020
DecodeManager: Detected 4 CPU core(s)
DecodeManager: Creating 4 decoder thread(s)
CConn: unable to create socket: Address family not supported by protocol
(97)
同样,如果我尝试连接到不存在的主机:
$ xtigervncviewer -AlertOnFatalError=0 nonexistinghost
TigerVNC Viewer 64-bit v1.9.0
Built on: 2020-01-23 18:03
Copyright (C) 1999-2018 TigerVNC Team and many others (see README.rst)
See http://www.tigervnc.org for information on TigerVNC.
Fri May 1 16:36:13 2020
DecodeManager: Detected 4 CPU core(s)
DecodeManager: Creating 4 decoder thread(s)
CConn: unable to resolve host by name: Name or service not known
但是,在这两种情况下,返回码均为零:
$ echo $?
0
如何确定连接是否成功或连接错误?