Closed teohhanhui closed 3 weeks ago
Something we can do, in krun-server, is keep track of the children and, if there's one that's still alive when the main command exits, inform the user and keep waiting until Ctrl+C is hit, or there are no more children running.
This behavior would also work well with binfmt integration. First command run, even from a Desktop link, will start up the VM, which will be kept alive until the last command exits.
WDYT?
Sounds reasonable. I'll send a PR.
Did some digging: https://users.rust-lang.org/t/how-to-properly-close-a-tcplistener-in-multi-thread-server/87376
Track requests, not threads.
https://users.rust-lang.org/t/how-to-properly-close-a-tcplistener-in-multi-thread-server/87376/17
shutdown
does not affect accept
, only recv
... But OTOH, we don't need to care about the server thread being blocked on accept
, as long as all in-flight requests are handled (and also wait
for child processes to exit)... So, we in fact do NOT want to join
the server thread.
We also don't want to use Drop
as it's not unwind safe:
Okay, I think we really need to rethink our architecture here. This is not going to work in any user friendly way.
Waiting for children to exit still means new krun
invocations in the meantime would fail for no apparent reason. That's very bad UX.
It seems to me the only possible solution without involving a long-lived krun server running in the background would be: delay the shutdown if a new incoming connection is accept
ed. (If we do anything to stop listening, we're back to the above problem with new krun
invocations failing...)
I'll continue thinking and working on this.
(Continuing from https://github.com/slp/krun/pull/23#discussion_r1624008269)
With some real-world testing, it's entirely jarring behaviour from a user perspective.
Steps for reproduction:
krun FEXBash
krun FEXInterpreter steam
exit
fromFEXBash
Expected result: Steam should continue running.
Actual / observed behaviour: Steam is killed abruptly.