test/x11comp: don't hang if Xvfb is not available
If Xvfb is not present, posix_spawn still forks, but the child fails. In that case, since we left the write fd of the pipe open in the parent, we just kept waiting on the read() without noticing that the other side is dead. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
527bf96f9b
commit
fc95057c5f
|
@ -78,14 +78,18 @@ main(void)
|
||||||
goto err_ctx;
|
goto err_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(pipefds[1]);
|
||||||
|
|
||||||
display[0] = ':';
|
display[0] = ':';
|
||||||
ret = read(pipefds[0], display + 1, sizeof(display) - 1);
|
ret = read(pipefds[0], display + 1, sizeof(display) - 1);
|
||||||
assert(ret > 0 && 1 + ret < sizeof(display) - 1);
|
if (ret <= 0 || 1 + ret >= sizeof(display) - 1) {
|
||||||
|
ret = SKIP_TEST;
|
||||||
|
goto err_xvfd;
|
||||||
|
}
|
||||||
if (display[ret] == '\n')
|
if (display[ret] == '\n')
|
||||||
display[ret] = '\0';
|
display[ret] = '\0';
|
||||||
display[1 + ret] = '\0';
|
display[1 + ret] = '\0';
|
||||||
close(pipefds[0]);
|
close(pipefds[0]);
|
||||||
close(pipefds[1]);
|
|
||||||
|
|
||||||
conn = xcb_connect(display, NULL);
|
conn = xcb_connect(display, NULL);
|
||||||
if (xcb_connection_has_error(conn)) {
|
if (xcb_connection_has_error(conn)) {
|
||||||
|
|
Loading…
Reference in New Issue