在Kylin v10上编写了一个c++程序A, 这个程序是监听了linux底层的事件,只要用户操作触发了这类型的事件,就会启动程序A, 在程序A中满足条件时,又会启动另外一个qt开发的客户端程序,本机系统kylin v10 arm64。
实际情况是用户操作出发了事件后, 启动A, A启动B, 但是B启动不了,查看/tmp/log.txt, 查看到程序B的报错信息如上, 然而在本机系统上单独启动B , B程序正常启动。
只好google之, 根据以下的信息, 解决了自己的问题,各人的实际情况不同,我是在程序B的启动脚本中引入了export XAUTHORITY=本机.Xauthority的路径 ,解决了我的问题。
Accessing the X server requires two things:
- The
$DISPLAY
variable pointing to the correct display (usually:0
) - Proper authentication information
The authentication information can be explicitly specified via $XAUTHORITY
, and defaults to ~/.Xauthority
otherwise.
If $DISPLAY
and $XAUTHORITY
is set for your user, sudo
will set them for the new shell, too, and everything should work fine.
If they are not set, they will probably default to the wrong values and you cannot start and X applications.
In Debian $XAUTHORITY
is usually not set explicitly. Just add
export XAUTHORITY=~/.Xauthority
to your .bashrc
or explicitly say XAUTHORITY=~/.Xauthority sudo ...
and everything should work.
You can also use xauth list
to check whether proper authentication information are available。