summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-07-17 17:44:26 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-17 17:44:26 +0200
commitcee530bb23b78c0dfd18b0c2718cfe41286396df (patch)
tree1773a17edc3572b6f522ec877b935424106c2484 /src
parent92a1fd9e95954a557d6fe27b56f5ef1b89fc2f5e (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/killall.c5
-rw-r--r--src/core/killall.h2
-rw-r--r--src/core/main.c8
-rw-r--r--src/core/shutdown.c4
4 files changed, 11 insertions, 8 deletions
diff --git a/src/core/killall.c b/src/core/killall.c
index 5f589eaf4..6fcaf847c 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -150,7 +150,7 @@ static int killall(int sig) {
return n_processes;
}
-void broadcast_signal(int sig) {
+void broadcast_signal(int sig, bool wait) {
sigset_t mask, oldmask;
int n_processes;
@@ -169,7 +169,8 @@ void broadcast_signal(int sig) {
if (n_processes <= 0)
goto finish;
- wait_for_children(n_processes, &mask);
+ if (wait)
+ wait_for_children(n_processes, &mask);
finish:
sigprocmask(SIG_SETMASK, &oldmask, NULL);
diff --git a/src/core/killall.h b/src/core/killall.h
index 8b5bd52de..d08ac142f 100644
--- a/src/core/killall.h
+++ b/src/core/killall.h
@@ -22,6 +22,6 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-void broadcast_signal(int sig);
+void broadcast_signal(int sig, bool wait);
#endif
diff --git a/src/core/main.c b/src/core/main.c
index f1f8b21ae..022d05a31 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1692,9 +1692,11 @@ finish:
watchdog_close(true);
if (switch_root_dir) {
- /* Kill all remaining processes from the initrd */
- broadcast_signal(SIGTERM);
- broadcast_signal(SIGKILL);
+ /* Kill all remaining processes from the
+ * initrd, but don't wait for them, so that we
+ * can handle the SIGCHLD for them after
+ * deserializing. */
+ broadcast_signal(SIGTERM, false);
/* And switch root */
r = switch_root(switch_root_dir);
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 78dccfb72..105a60454 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -177,10 +177,10 @@ int main(int argc, char *argv[]) {
mlockall(MCL_CURRENT|MCL_FUTURE);
log_info("Sending SIGTERM to remaining processes...");
- broadcast_signal(SIGTERM);
+ broadcast_signal(SIGTERM, true);
log_info("Sending SIGKILL to remaining processes...");
- broadcast_signal(SIGKILL);
+ broadcast_signal(SIGKILL, true);
if (in_container) {
need_swapoff = false;