在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 sayXAUTHORITY=~/.Xauthority sudo ...
and everything should work.
You can also usexauth list
to check whether proper authentication information are available。