Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark service dirty if the command line args have changed #333

Merged
merged 1 commit into from
Jan 4, 2023

Conversation

JackNewman12
Copy link
Contributor

This fixes initctl reload correctly restarting all daemons that have new command line arguments.
Previously command line arguments changes were only acted upon if the service was explicitly reloaded using initctl reload myservice since it blindly sets the svc->dirty flag.

When checking if a service should be restarted, svc_is_changed() checks for the svc->dirty flag, and then only after that will svc_sighup() look for the svc->args_dirty flag. Hence a difference in command line arguments would not result in a service being restarted.

finit/src/service.c

Lines 2289 to 2293 in 9887003

case COND_ON:
if (svc_is_changed(svc)) {
if (svc_nohup(svc))
service_stop(svc);
else {

You could also add the || svc->args_dirty check into the svc_is_changed(), but I think it makes sense this way.

This fixes `initctl reload` correctly restarting all daemons that have new
command line arguments.

Previously command line arguments changes were only acted upon if the
service was explicitly reloaded `initctl reload myservice`.
@troglobit
Copy link
Owner

Nice catch, thanks!

Dunno why one of the tests fail. Running the same patch on my local system is 100% success. So I'm merging this and moving on to the next PR. If the test issue remains I'll have a look at that separately, because your patch is sound regardless.

@troglobit troglobit merged commit 0de4578 into troglobit:master Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants