简体   繁体   English

recvfrom for X11-unix socket正在抛出EAGAIN(资源暂时不可用)

[英]recvfrom for X11-unix socket is throwing EAGAIN (Resource temporarily unavailable)

I want to capture web page by pywebkitgtk. 我想通过pywebkitgtk捕获网页。 I have installed the X org server on that machine, started the X server with some exceptions, but the X server is running. 我在那台机器上安装了X org服务器,启动了X服务器但有一些例外,但X服务器正在运行。 Issue is I'm not able to read any data from the X unix socket, which is PF_FILE type with path=@"/tmp/.X11-unix/X0", recvfrom is throwing EAGAIN (Resource temporarily unavailable) error, polling against that socket constantly time out without any coming data, below is the trace log, in which we can find successfully created unix socket with fd 5, connected unix socket, succeed so far, but failed to read anything from that unix socket. 问题是我无法从X unix套接字读取任何数据,这是PF_FILE类型,路径= @“/ tmp / .X11-unix / X0”,recvfrom正在抛出EAGAIN(资源暂时不可用)错误,轮询该套接字不断超时而没有任何即将到来的数据,下面是跟踪日志,我们可以在其中找到成功创建的带有fd 5的unix套接字,连接的unix套接字,到目前为止成功,但无法从该unix套接字读取任何内容。

developer@kernel: /data/play/null> strace python ../pywebkitgtk-1.1.8/demos/browser.py

socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC, 0) = 5
connect(5, {sa_family=AF_FILE, path=@"/tmp/.X11-unix/X0"}, 20) = 0
getpeername(5, {sa_family=AF_FILE, path=@"/tmp/.X11-unix/X0"}, [20]) = 0


...........................


recvfrom(5, "\1\3\304\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"\220\10\7\0\0\1G\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \1", 28}, {NULL, 0}, {"", 0}], 3) = 28
poll([{fd=5, events=POLLIN}], 1, -1)    = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "\1\3\305\1X\4\0\0\0\0\10\377G\0\0\31\31\0104\1\370\0\0\0\0\0\0\0\0\0\0\10"..., 4096, 0, NULL, NULL) = 4096
recvfrom(5, "\216\377\10\20\0\0\0\0\1\1\1\0\33\377\10\20\0\0\0\0\1\1\1\0_\377\10\20\0\0\0\0"..., 384, 0, NULL, NULL) = 384
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"\220\21\3\0\3\0G\0\0\30\0\0", 12}, {NULL, 0}, {"", 0}], 3) = 12
poll([{fd=5, events=POLLIN}], 1, -1)    = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "\1\3\306\1\16\0\0\0\0\30\0\0\10\377\31\1\377\37\10\370\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 0, NULL, NULL) = 88
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"\20\0\3\0\4\0G\0Meta", 12}, {NULL, 0}, {"", 0}], 3) = 12
poll([{fd=5, events=POLLIN}], 1, -1)    = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "\1\0\307\1\0\0\0\0\206\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"\20\0\4\0\5\0G\0Super\0\0\0", 16}, {NULL, 0}, {"", 0}], 3) = 16
poll([{fd=5, events=POLLIN}], 1, -1)    = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "\1\0\310\1\0\0\0\0\207\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"\20\0\4\0\5\0G\0Hyper\0\0\0", 16}, {NULL, 0}, {"", 0}], 3) = 16
poll([{fd=5, events=POLLIN}], 1, -1)    = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "\1\0\311\1\0\0\0\0\210\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{";\3\5\0\16\0 \1\0\0\0\0\3\0\3\0\316\2\22\0008\0\5\0\16\0 \1\0000\0\0"..., 16384}, {NULL, 0}, {"", 0}], 3) = 16384
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"6\3\2\0f\0 \1", 8}, {NULL, 0}, {"", 0}], 3) = 8
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN}, {fd=5, events=POLLIN}], 2, 0) = 0 (Timeout)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN}, {fd=5, events=POLLIN}], 2, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"5\30\4\0\200\0 \1\3\0 \1\316\2\22\0\223\4\5\0\201\0 \1\200\0 \1)\0\0\0"..., 296}, {NULL, 0}, {"", 0}], 3) = 296
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN}, {fd=5, events=POLLIN}], 2, 497) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=5, revents=POLLOUT}])
writev(5, [{"(\30\4\0\3\0 \1\1\1\0\0\0\0\0\0", 16}, {NULL, 0}, {"", 0}], 3) = 16
poll([{fd=5, events=POLLIN}], 1, -1)    = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "\1\1#\2\0\0\0\0\250\3\300\0o\0N\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN}, {fd=5, events=POLLIN}], 2, 4498) = 0 (Timeout)
futex(0x7f2d8af5ea9c, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x7f2d8af5ea98, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
recvfrom(5, 0x25ff6c4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)

Somewhere in the .... part the socket was marked as non-blocking, so getting EAGAIN (which is the same errno(3) value as EWOULDBLOCK , btw) is totally normal - it means there's no data to consume at that particular moment. ....某个部分,套接字被标记为非阻塞,因此获取EAGAIN (与EWOULDBLOCK ,btw相同的errno(3)值)是完全正常的 - 这意味着在该特定时刻没有数据要消耗。

Then your trace does show that you do get data from the socket every time after poll(2) with revents=POLLIN , so I don't see anything wrong here. 然后你的跟踪确实显示每次使用revents=POLLIN进行poll(2)之后都会从套接字获取数据 ,所以我在这里看不到任何错误。 Maybe just the fact that the unsuccessful read is always repeated twice, but that's not a real issue, just inefficiency (or maybe the other way around - some very clever trick). 也许只是不成功的读取总是重复两次这一事实,但这不是一个真正的问题,只是效率低下(或者反过来说 - 一些非常聪明的技巧)。

Have you sent X11 protocol requests on the Unix socket that you're expecting replies from? 您是否在Unix套接字上发送了X11协议请求,您希望收到回复? After the initial X11 protocol handshake, you won't get anything from the X server until you request it - either via a request that returns an immediate response or one that registers you for later events. 在初始X11协议握手之后,在您请求之前,您将无法从X服务器获得任何内容 - 通过返回立即响应的请求或注册您以后的事件的请求。

The X11 protocol is complex enough that trying to write your own code to connect to it is a far larger task than anyone should do - you should use the libxcb or libX11 libraries to handle the protocol for you, and a higher level toolkit such as GTK or Qt to handle most of the widgets and user interface. X11协议非常复杂,试图编写自己的代码来连接它是一个比任何人都要做的要大得多的任务 - 你应该使用libxcb或libX11库为你处理协议,以及更高级别的工具包,如GTK或Qt来处理大多数小部件和用户界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 timer_create(): - 1 EAGAIN(资源暂时不可用) - timer_create() : -1 EAGAIN (Resource temporarily unavailable) 为什么STRACE显示EAGAIN(资源暂时不可用) - Why STRACE shows EAGAIN (Resource temporarily unavailable) 资源暂时不可用,UDP套接字 - Resource temporarily unavailable, UDP socket Connect() 到 unix:/var/run/php-fpm.sock 连接到上游时失败(11:资源暂时不可用),客户端:unix:,服务器 - Connect() to unix:/var/run/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: unix:, server 如何解决pthread_create错误(11)资源暂时不可用? - How to solve pthread_create error (11) resource temporarily unavailable? Docker/Puppeteer: pthread_create: 资源暂时不可用 (11) - Docker/Puppeteer : pthread_create: Resource temporarily unavailable (11) C# 资源暂时不可用,并在 linux 上的 dotnet 核心上阻塞套接字 - C# Resource temporarily unavailable with blocking socket on dotnet core on linux recvmsg()返回“资源暂时不可用” - recvmsg() returns “Resource temporarily unavailable” poll()和read()“资源暂时不可用” - poll() and read() “resource temporarily unavailable” 接受时出错:资源暂时不可用 - ERROR on accept: Resource temporarily unavailable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM