Repository navigation
Add EXIT_ON_APP_CLOSE to stop the container when the app exits - #200
Merged
thelamer merged 1 commit intoNov 19, 2026
Merged
Conversation
junkerderprovinz
force-pushed
the
feat/exit-on-app-close
branch
from
November 11, 2026 10:22
8788521 to
6a41579
Compare
junkerderprovinz
force-pushed
the
feat/exit-on-app-close
branch
from
November 18, 2026 19:50
6a41579 to
2a41cb3
Compare
Contributor
Author
|
Rebased onto dev. Since c4dede0 removed svc-watchdog, the change is now a small svc-app-exit service: it waits for the autostart's lock on $XDG_RUNTIME_DIR/selkies-autostart.lock, reads /proc/locks so it never takes the lock itself, and halts the container once the lock is released. init-selkies-config also removes the lock file left from the last run, so an app that quits right away still stops the container. I've updated the description and the test notes to match. |
thelamer
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have read the contributing guideline and understand that I have made the correct modifications
An LLM assisted me in writing the code or text for this PR
An LLM agent wrote the code or text for this PR
Description:
Hi! This adds
EXIT_ON_APP_CLOSE. When it istrue, a small s6 service,svc-app-exit, stops the container once the autostart app and everything it started have exited. Selkies holds a lock on$XDG_RUNTIME_DIR/selkies-autostart.lockfor that whole time, so the service waits for the lock file to appear and then for the lock to disappear from/proc/locks. It only reads/proc/locks, so selkies never finds the lock taken, and it matches by inode becauselslockscannot resolve the path inside a container. Then it calls s6'shalt, the same waydocker stopshuts down, and the container exits with code 0.init-selkies-configremoves the lock file left from the last run, so an app that quits right away still stops the container. IfRESTART_APPis set as well, exiting wins, andinit-selkies-configleavesSELKIES_APP_RESTARTunset. The same goes forHARDEN_OPENBOX, which turns onRESTART_APPunless you set it yourself. Without the variable the service just sleeps. I used AI as a helper for the change and this text.Benefits of this PR and context:
Closes #198. Single-app images like chromium can then run as throwaway containers: start one with
--rmor--restart=no, close the app, and the container is gone. With a restart policy likeunless-stopped, Docker would just start it again. The change is one small service plus two lines ininit-selkies-config. A mod could add the service, but it would also have to patchinit-selkies-configto keepRESTART_APPfrom bringing the app back. Happy to rename the variable if you prefer another name, and if this lands I'll document it in docker-documentation (security and baseimage-internals pages), as I did forDISABLE_WINDOW_BUTTONSin linuxserver/docker-documentation#51. Thanks for having a look!How Has This Been Tested?
I mounted the changed files into the published
devimage (fff78f27-ls17, built fromcce318a) on Unraid, with a script runningsleep 20as the autostart app. X11, Wayland (PIXELFLUX_WAYLAND=trueon an RTX 4070 Ti SUPER) and X11 withRESTART_APP=trueeach logged[svc-app-exit] Application has exited. Stopping the container...within a second of the app closing, and the container exited with code 0 four to five seconds after the app. WithRESTART_APPthe app ran only once. If the app leaves a child running for another 10 seconds, the container waits for the child. An app that quits after one second also stops the container, and a second start on the same/configwaits for the new run. Without the variable the container kept running.Source / References:
#198