switch-root: don't wait for processes
When we transition from the initrd to the main system, don't reap processes, so that they can be handled normally after deserialization.
This commit is contained in:
parent
92a1fd9e95
commit
cee530bb23
2
TODO
2
TODO
|
@ -34,8 +34,6 @@ Bugfixes:
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
* switch-root killing spree: don't waitpid, and think about signalfd() serialization
|
|
||||||
|
|
||||||
* flush jobs when switching root
|
* flush jobs when switching root
|
||||||
|
|
||||||
* autorestart of journald after switch-root is broken
|
* autorestart of journald after switch-root is broken
|
||||||
|
|
|
@ -150,7 +150,7 @@ static int killall(int sig) {
|
||||||
return n_processes;
|
return n_processes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void broadcast_signal(int sig) {
|
void broadcast_signal(int sig, bool wait) {
|
||||||
sigset_t mask, oldmask;
|
sigset_t mask, oldmask;
|
||||||
int n_processes;
|
int n_processes;
|
||||||
|
|
||||||
|
@ -169,7 +169,8 @@ void broadcast_signal(int sig) {
|
||||||
if (n_processes <= 0)
|
if (n_processes <= 0)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
wait_for_children(n_processes, &mask);
|
if (wait)
|
||||||
|
wait_for_children(n_processes, &mask);
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
sigprocmask(SIG_SETMASK, &oldmask, NULL);
|
sigprocmask(SIG_SETMASK, &oldmask, NULL);
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void broadcast_signal(int sig);
|
void broadcast_signal(int sig, bool wait);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1692,9 +1692,11 @@ finish:
|
||||||
watchdog_close(true);
|
watchdog_close(true);
|
||||||
|
|
||||||
if (switch_root_dir) {
|
if (switch_root_dir) {
|
||||||
/* Kill all remaining processes from the initrd */
|
/* Kill all remaining processes from the
|
||||||
broadcast_signal(SIGTERM);
|
* initrd, but don't wait for them, so that we
|
||||||
broadcast_signal(SIGKILL);
|
* can handle the SIGCHLD for them after
|
||||||
|
* deserializing. */
|
||||||
|
broadcast_signal(SIGTERM, false);
|
||||||
|
|
||||||
/* And switch root */
|
/* And switch root */
|
||||||
r = switch_root(switch_root_dir);
|
r = switch_root(switch_root_dir);
|
||||||
|
|
|
@ -177,10 +177,10 @@ int main(int argc, char *argv[]) {
|
||||||
mlockall(MCL_CURRENT|MCL_FUTURE);
|
mlockall(MCL_CURRENT|MCL_FUTURE);
|
||||||
|
|
||||||
log_info("Sending SIGTERM to remaining processes...");
|
log_info("Sending SIGTERM to remaining processes...");
|
||||||
broadcast_signal(SIGTERM);
|
broadcast_signal(SIGTERM, true);
|
||||||
|
|
||||||
log_info("Sending SIGKILL to remaining processes...");
|
log_info("Sending SIGKILL to remaining processes...");
|
||||||
broadcast_signal(SIGKILL);
|
broadcast_signal(SIGKILL, true);
|
||||||
|
|
||||||
if (in_container) {
|
if (in_container) {
|
||||||
need_swapoff = false;
|
need_swapoff = false;
|
||||||
|
|
Loading…
Reference in New Issue