diff options
-rw-r--r-- | src/firejail/x11.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/firejail/x11.c b/src/firejail/x11.c index 8f9a4c11f..e09bb3411 100644 --- a/src/firejail/x11.c +++ b/src/firejail/x11.c | |||
@@ -199,23 +199,32 @@ void x11_start(int argc, char **argv) { | |||
199 | perror("execvp"); | 199 | perror("execvp"); |
200 | exit(1); | 200 | exit(1); |
201 | } | 201 | } |
202 | sleep(1); | ||
203 | |||
204 | if (arg_debug) { | ||
205 | printf("X11 sockets: "); fflush(0); | ||
206 | int rv = system("ls /tmp/.X11-unix"); | ||
207 | (void) rv; | ||
208 | } | ||
209 | 202 | ||
210 | // check X11 socket | 203 | // check X11 socket |
211 | char *fname; | 204 | char *fname; |
212 | if (asprintf(&fname, "/tmp/.X11-unix/X%d", display) == -1) | 205 | if (asprintf(&fname, "/tmp/.X11-unix/X%d", display) == -1) |
213 | errExit("asprintf"); | 206 | errExit("asprintf"); |
214 | if (stat(fname, &s) == -1) { | 207 | int n = 0; |
208 | // wait for x11 server to start | ||
209 | while (++n < 10) { | ||
210 | sleep(1); | ||
211 | if (stat(fname, &s) == 0) | ||
212 | break; | ||
213 | }; | ||
214 | |||
215 | if (n == 10) { | ||
215 | fprintf(stderr, "Error: failed to start xpra\n"); | 216 | fprintf(stderr, "Error: failed to start xpra\n"); |
216 | exit(1); | 217 | exit(1); |
217 | } | 218 | } |
219 | free(fname); | ||
220 | sleep(1); | ||
218 | 221 | ||
222 | if (arg_debug) { | ||
223 | printf("X11 sockets: "); fflush(0); | ||
224 | int rv = system("ls /tmp/.X11-unix"); | ||
225 | (void) rv; | ||
226 | } | ||
227 | |||
219 | // run attach command | 228 | // run attach command |
220 | client = fork(); | 229 | client = fork(); |
221 | if (client < 0) | 230 | if (client < 0) |