cage: Cage doesn't exit when all clients are gone

Regressed by #132 (5d7ff9e64dc7). Cage works nicely as a nested compositor for running multiple applications with minimalistic UI in fullscreen mode or Wayland-only applications on X11. Unfortunately, Cage no longer exits on its own and ignores SIGTERM and SIGINT.

$ cage -d firefox --kiosk --profile $(mktemp -dt ffprofile) https://www.youtube.com/embed/hVvEISFw9w0
<press Ctrl+Q to quit Firefox>
[types/seat/wlr_seat_pointer.c:364] button_count=1 grab_serial=23 serial=25
[types/seat/wlr_seat_pointer.c:364] button_count=0 grab_serial=25 serial=26
[types/wlr_idle.c:186] Enabling idle timers for all seats
[wayland] failed to read client connection (pid 18480)
[wayland] failed to read client connection (pid 18418)
[wayland] failed to read client connection (pid 18638)
[wayland] failed to read client connection (pid 18492)
load: 9.21  cmd: cage 18186 [select] 22.46r 0.17u 0.07s 0% 77748k
^C^C
[xwayland/xwm.c:844] XCB_DESTROY_NOTIFY (4194305)
load: 9.12  cmd: Xwayland 18200 [uwait] 24.94r 0.03u 0.00s 0% 35164k
^C^C
<press Super+Shift+q or similar to kill Cage via parent compositor>
[../cage.c:139] Child exited normally with exit status 0
$ cage -d firefox --kiosk --profile $(mktemp -dt ffprofile) https://www.youtube.com/embed/hVvEISFw9w0
^C
[wayland] failed to read client connection (pid 91482)
[xwayland/xwm.c:844] XCB_DESTROY_NOTIFY (4194305)
load: 0.45  cmd: firefox 91482 [zombie] 12.18r 4.89u 1.10s 7% 0k
^C
<press Super+Shift+q or similar to kill Cage via parent compositor>
[../cage.c:141] Child was terminated by a signal (2)
(lldb) bt
* thread #1, name = 'cage'
  * frame #0: 0x0000000800632dfa libc.so.7`__sys_poll at _poll.S:4
    frame #1: 0x0000000800902946 libthr.so.3`__thr_poll(fds=<unavailable>, nfds=<unavailable>, timeout=<unavailable>) at thr_syscalls.c:338:8
    frame #2: 0x00000008008df1f2 libepoll-shim.so.0`epollfd_ctx_wait_or_block(epollfd=0x0000000801448028, ev=0x00007fffffffdc40, cnt=32, actual_cnt=0x00007fffffffdbf4, to=-1) at epoll.c:211:7
    frame #3: 0x00000008008dee91 libepoll-shim.so.0`epoll_wait(fd=3, ev=0x00007fffffffdc40, cnt=32, to=-1) at epoll.c:230:12
    frame #4: 0x0000000800265be9 libwayland-server.so.0`wl_event_loop_dispatch(loop=0x0000000801439320, timeout=-1) at event-loop.c:1004:10
    frame #5: 0x00000008002618df libwayland-server.so.0`wl_display_run(display=0x0000000801459000) at wayland-server.c:1401:3
    frame #6: 0x0000000000208d25 cage`main(argc=7, argv=0x00007fffffffe038) at cage.c:486:2
    frame #7: 0x0000000000207e2f cage`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76:7
(lldb) f 6
frame #6: 0x0000000000208d25 cage`main(argc=7, argv=0x00007fffffffdff0) at cage.c:486:2
   483          struct wlr_box *layout_box = wlr_output_layout_get_box(server.output_layout, NULL);
   484          wlr_cursor_warp(server.seat->cursor, NULL, layout_box->width / 2, layout_box->height / 2);
   485
-> 486          wl_display_run(server.wl_display);
   487
   488  #if CAGE_HAS_XWAYLAND
   489          wlr_xwayland_destroy(xwayland);
(lldb) f 5
frame #5: 0x00000008002618df libwayland-server.so.0`wl_display_run(display=0x0000000801459000) at wayland-server.c:1401:3
   1398
   1399         while (display->run) {
   1400                 wl_display_flush_clients(display);
-> 1401                 wl_event_loop_dispatch(display->loop, -1);
   1402         }
   1403 }
   1404
(lldb) f 2
frame #2: 0x00000008008df1f2 libepoll-shim.so.0`epollfd_ctx_wait_or_block(epollfd=0x0000000801448028, ev=0x00007fffffffdc00, cnt=32, actual_cnt=0x00007fffffffdbb4, to=-1) at epoll.c:211:7
   208                  pfds[1] = epollfd->pfds[1];
   209                  (void)pthread_mutex_unlock(&epollfd->mutex);
   210
-> 211                  if (poll(pfds, 2, MAX(to, -1)) < 0) {
   212                          return errno;
   213                  }
   214          }

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@Hjdskes, correct. Killing clients inside Cage works fine as Cage exists after a few seconds when all are gone but when Cage itself is killed it doesn’t exit gracefully but crashes.

@Hjdskes, I did test with Wayland backend via MOZ_ENABLE_WAYLAND=1. It was not important enough to mention because GDK_BACKEND=wayland is default on a Wayland compositor. Other Gtk3 apps don’t require fiddling with envirnoment variables.

@myfreeweb, do you think libwayland dependency on libepoll-shim can cause FreeBSD to behave unlike Linux in this case?