Allow an onrestart command to stop the current service

For example,

service recovery /sbin/recovery
	onrestart start loadkeys
	onrestart class_start con
	onrestart stop recovery

Previously, if you had a service like the above, the "onrestart stop
recovery" clause would not have any effect, because the restart flag
would be re-set after the stop command had executed.

This is similar to a service with the "oneshot" keyword, with the critical
difference being that it executes the other onrestart commands when the
service dies.
This commit is contained in:
Ben Gruver 2009-01-13 20:43:30 -06:00 committed by Jean-Baptiste Queru
parent e7cb137f32
commit dc816d5dcd

3
init/init.c Normal file → Executable file
View file

@ -389,12 +389,13 @@ static int wait_for_one_process(int block)
}
}
svc->flags |= SVC_RESTARTING;
/* Execute all onrestart commands for this service. */
list_for_each(node, &svc->onrestart.commands) {
cmd = node_to_item(node, struct command, clist);
cmd->func(cmd->nargs, cmd->args);
}
svc->flags |= SVC_RESTARTING;
notify_service_state(svc->name, "restarting");
return 0;
}