mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
Wait only one second at shutdown/reboot for lingering processes
Transitioning to runlevel 0 or 6 handles graceful shutdown of any managed run/task/sysv/services. So we can replace the old 2 sec delay with a shorter one for any non-managed still lingering process. Also, some minor cleanup. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
2c12379a30
commit
30e3f5a33c
1 file changed
+9
-9
@@ -192,10 +192,10 @@ void do_kill(int signo)
|
|||||||
if (fgets(file, sizeof(file), fp)) {
|
if (fgets(file, sizeof(file), fp)) {
|
||||||
if (strstr(file, "gdbserver"))
|
if (strstr(file, "gdbserver"))
|
||||||
_d("Skipping %s ...", file);
|
_d("Skipping %s ...", file);
|
||||||
else if (file[0] != '@')
|
else if (file[0] == '@')
|
||||||
kill(pid, signo);
|
|
||||||
else
|
|
||||||
_d("Skipping %s ...", &file[1]);
|
_d("Skipping %s ...", &file[1]);
|
||||||
|
else
|
||||||
|
kill(pid, signo);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
@@ -214,11 +214,11 @@ void do_shutdown(shutop_t op)
|
|||||||
utmp_set_halt();
|
utmp_set_halt();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tell all remaining non-monitored processes to exit, give them
|
* Tell remaining non-monitored processes to exit, give them
|
||||||
* some time to exit gracefully, 2 sec is customary.
|
* time to exit gracefully, 2 sec was customary, we go for 1.
|
||||||
*/
|
*/
|
||||||
do_kill(SIGTERM);
|
do_kill(SIGTERM);
|
||||||
do_sleep(2);
|
do_sleep(1);
|
||||||
do_kill(SIGKILL);
|
do_kill(SIGKILL);
|
||||||
|
|
||||||
/* Exit plugins and API gracefully */
|
/* Exit plugins and API gracefully */
|
||||||
@@ -274,15 +274,15 @@ void do_shutdown(shutop_t op)
|
|||||||
do_sleep(1);
|
do_sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_e("Rebooting ...");
|
_d("Rebooting ...");
|
||||||
reboot(RB_AUTOBOOT);
|
reboot(RB_AUTOBOOT);
|
||||||
} else if (op == SHUT_OFF) {
|
} else if (op == SHUT_OFF) {
|
||||||
_e("Powering down ...");
|
_d("Powering down ...");
|
||||||
reboot(RB_POWER_OFF);
|
reboot(RB_POWER_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Also fallback if any of the other two fails */
|
/* Also fallback if any of the other two fails */
|
||||||
_e("Halting ...");
|
_d("Halting ...");
|
||||||
reboot(RB_HALT_SYSTEM);
|
reboot(RB_HALT_SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user