Repository navigation
Conversation
nbd168
commented
Oct 15, 2026
Contributor
- allow passing a prepare function to uloop.process()
- properly handle exit() in callbacks
nbd168
force-pushed
the
uloop
branch
2 times, most recently
from
October 17, 2026 18:04
f34096b to
bd05296
Compare
Since the exception guard was added, uc_uloop_vm_call() hands every exception of a callback to the guard handler, also the EXCEPTION_EXIT that exit() raises. The guard receives an "Exit" exception and the loop keeps running. When run() returns, the script ends with code 0 instead of the code given to exit(), because the VM already reset its call frames for the exit request. End the loop and keep the exit request pending, as without a guard, so that the script terminates with the requested code. Fixes: aaf712e ("uloop: add guard() function") Signed-off-by: Felix Fietkau <nbd@nbd.name>
A program started by uloop.process() can need preparatory work in the child before exec(), for example to redirect a file descriptor. Accept a function instead of the executable path. The function runs in the child after fork(), receives the argument vector and the environment, and returns the complete argument vector to execute. Changes to the environment object apply to the executed program. exit() in the function sets the exit code of the child. If the function throws an exception or does not return a non-empty array, the child exits with code 255, the same as for a failed exec(). Release the event loop in the child before the function runs, like uloop.task() does. The child otherwise shares the signal pipe of the parent, so a signal sent to the child runs signal callbacks of the parent, and SIGTERM does not end the child. Flush the output of the parent before fork(), since a flush in the child writes the inherited buffer a second time. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This branch has not been deployed
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.