mirror of
https://github.com/troglobit/finit.git
synced 2026-10-05 23:33:36 +07: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:
+13
-7
@@ -500,20 +500,25 @@ void networking(int updown)
|
||||
if (fexist("/etc/network/interfaces")) {
|
||||
pid_t pid;
|
||||
|
||||
if (!updown) {
|
||||
run_interactive("ifdown -a", "Stopping networking");
|
||||
goto done;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
int rc = EX_OSERR;
|
||||
const char *cmd;
|
||||
FILE *pp;
|
||||
|
||||
setsid();
|
||||
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) {
|
||||
char buf[256];
|
||||
|
||||
@@ -526,7 +531,8 @@ void networking(int updown)
|
||||
_exit(rc);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user