+static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
+ Swap *s = SWAP(u);
+ bool success;
+
+ assert(s);
+ assert(pid >= 0);
+
+ if (pid != s->control_pid)
+ return;
+
+ s->control_pid = 0;
+
+ success = is_clean_exit(code, status);
+ s->failure = s->failure || !success;
+
+ if (s->control_command) {
+ exec_status_exit(&s->control_command->exec_status, pid, code, status, s->exec_context.utmp_id);
+ s->control_command = NULL;
+ s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
+ }
+
+ log_full(success ? LOG_DEBUG : LOG_NOTICE,
+ "%s swap process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
+
+ switch (s->state) {
+
+ case SWAP_ACTIVATING:
+ case SWAP_ACTIVATING_SIGTERM:
+ case SWAP_ACTIVATING_SIGKILL:
+
+ if (success)
+ swap_enter_active(s, true);
+ else
+ swap_enter_dead(s, false);
+ break;
+
+ case SWAP_DEACTIVATING:
+ case SWAP_DEACTIVATING_SIGKILL:
+ case SWAP_DEACTIVATING_SIGTERM:
+
+ if (success)
+ swap_enter_dead(s, true);
+ else
+ swap_enter_dead(s, false);
+ break;
+
+ default:
+ assert_not_reached("Uh, control process died at wrong time.");
+ }
+
+ /* Notify clients about changed exit status */
+ unit_add_to_dbus_queue(u);
+
+ /* Request a reload of /proc/swaps, so that following units
+ * can follow our state change */
+ u->meta.manager->request_reload = true;
+}
+
+static void swap_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
+ Swap *s = SWAP(u);
+
+ assert(s);
+ assert(elapsed == 1);
+ assert(w == &s->timer_watch);
+
+ switch (s->state) {
+
+ case SWAP_ACTIVATING:
+ log_warning("%s activation timed out. Stopping.", u->meta.id);
+ swap_enter_signal(s, SWAP_ACTIVATING_SIGTERM, false);
+ break;
+
+ case SWAP_DEACTIVATING:
+ log_warning("%s deactivation timed out. Stopping.", u->meta.id);
+ swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, false);
+ break;
+
+ case SWAP_ACTIVATING_SIGTERM:
+ if (s->exec_context.send_sigkill) {
+ log_warning("%s activation timed out. Killing.", u->meta.id);
+ swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, false);
+ } else {
+ log_warning("%s activation timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ swap_enter_dead(s, false);
+ }
+ break;
+
+ case SWAP_DEACTIVATING_SIGTERM:
+ if (s->exec_context.send_sigkill) {
+ log_warning("%s deactivation timed out. Killing.", u->meta.id);
+ swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, false);
+ } else {
+ log_warning("%s deactivation timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ swap_enter_dead(s, false);
+ }
+ break;
+
+ case SWAP_ACTIVATING_SIGKILL:
+ case SWAP_DEACTIVATING_SIGKILL:
+ log_warning("%s swap process still around after SIGKILL. Ignoring.", u->meta.id);
+ swap_enter_dead(s, false);
+ break;
+
+ default:
+ assert_not_reached("Timeout at wrong time.");
+ }
+}
+
+static int swap_load_proc_swaps(Manager *m, bool set_flags) {
+ unsigned i;
+ int r = 0;
+
+ assert(m);
+