mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
Follow-up to ef9e9ec, run ifdown also in background, with --force
Turns out that on Debian `ifdown -a` can block for quite a while at shutdown/reboot. So we'd like to use the --force option. However, the BusyBox ifdown tool doesn't support --force, only -f, which in turn the regular ifdown tool doesn't support. Regardless, we can allow network shutdown to run in the background like bring-up, at reboot we want to reboot quickly and don't care so much, and on runlevel change to single-user mode we can allow for some lagging behind in the background. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
3e51ed1c55
commit
cfc99c4e8b
1 file changed
+13
-7
+13
-7
@@ -500,20 +500,25 @@ void networking(int updown)
|
|||||||
if (fexist("/etc/network/interfaces")) {
|
if (fexist("/etc/network/interfaces")) {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if (!updown) {
|
|
||||||
run_interactive("ifdown -a", "Stopping networking");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
int rc = EX_OSERR;
|
int rc = EX_OSERR;
|
||||||
|
const char *cmd;
|
||||||
FILE *pp;
|
FILE *pp;
|
||||||
|
|
||||||
setsid();
|
setsid();
|
||||||
sig_unblock();
|
sig_unblock();
|
||||||
|
|
||||||
pp = popen("ifup -a 2>&1", "r");
|
if (updown)
|
||||||
|
cmd = "ifup -a 2>&1";
|
||||||
|
else if (whichp("ifquery"))
|
||||||
|
/* Regular ifodwn supports --force but not -f */
|
||||||
|
cmd = "ifdown -a --force 2>&1";
|
||||||
|
else
|
||||||
|
/* Busybox ifdown support -f, but not --force */
|
||||||
|
cmd = "ifdown -a -f 2>&1";
|
||||||
|
|
||||||
|
pp = popen(cmd, "r");
|
||||||
if (pp) {
|
if (pp) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
@@ -526,7 +531,8 @@ void networking(int updown)
|
|||||||
_exit(rc);
|
_exit(rc);
|
||||||
}
|
}
|
||||||
cgroup_service("network", pid, NULL);
|
cgroup_service("network", pid, NULL);
|
||||||
print(pid > 0 ? 0 : 1, "Bringing up network interfaces ...");
|
print(pid > 0 ? 0 : 1, "%s network interfaces ...",
|
||||||
|
updown ? "Bringing up" : "Taking down");
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user