mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-06-28 13:14:15 -04:00
Merge 0b9e1fa170 into e5db9506b4
This commit is contained in:
commit
8fca769e78
1 changed files with 25 additions and 5 deletions
30
cage.c
30
cage.c
|
|
@ -198,8 +198,25 @@ cleanup_primary_client(pid_t pid)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
wlr_log(WLR_DEBUG, "Sending SIGTERM to child with pid %d", pid);
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
|
||||||
|
/* 100 ms in nanoseconds */
|
||||||
|
struct timespec ts = {0, 100000000};
|
||||||
|
|
||||||
|
/* 10 sec timeout with 100ms intervals */
|
||||||
|
for(int i = 0; i < 100; i++) {
|
||||||
|
if(waitpid(pid, &status, WNOHANG) > 0) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(WLR_INFO, "Child did not exit after 10s, sending SIGKILL");
|
||||||
|
kill(pid, SIGKILL);
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
||||||
|
done:
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
wlr_log(WLR_DEBUG, "Child exited normally with exit status %d", WEXITSTATUS(status));
|
wlr_log(WLR_DEBUG, "Child exited normally with exit status %d", WEXITSTATUS(status));
|
||||||
return WEXITSTATUS(status);
|
return WEXITSTATUS(status);
|
||||||
|
|
@ -655,6 +672,14 @@ main(int argc, char *argv[])
|
||||||
seat_center_cursor(server.seat);
|
seat_center_cursor(server.seat);
|
||||||
wl_display_run(server.wl_display);
|
wl_display_run(server.wl_display);
|
||||||
|
|
||||||
|
if (pid != 0) {
|
||||||
|
app_ret = cleanup_primary_client(pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret && server.return_app_code) {
|
||||||
|
ret = app_ret;
|
||||||
|
}
|
||||||
|
|
||||||
#if CAGE_HAS_XWAYLAND
|
#if CAGE_HAS_XWAYLAND
|
||||||
if (xwayland) {
|
if (xwayland) {
|
||||||
wl_list_remove(&server.new_xwayland_surface.link);
|
wl_list_remove(&server.new_xwayland_surface.link);
|
||||||
|
|
@ -680,11 +705,6 @@ main(int argc, char *argv[])
|
||||||
wl_list_remove(&server.output_layout_change.link);
|
wl_list_remove(&server.output_layout_change.link);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (pid != 0)
|
|
||||||
app_ret = cleanup_primary_client(pid);
|
|
||||||
if (!ret && server.return_app_code)
|
|
||||||
ret = app_ret;
|
|
||||||
|
|
||||||
wl_event_source_remove(sigint_source);
|
wl_event_source_remove(sigint_source);
|
||||||
wl_event_source_remove(sigterm_source);
|
wl_event_source_remove(sigterm_source);
|
||||||
if (sigchld_source) {
|
if (sigchld_source) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue