]> git.proxmox.com Git - ifupdown2.git/blame - debian/patches/upstream/0001-scheduler-avoid-waiting-for-stdout-eof-of-etc-networ.patch
fix #5009: avoid waiting for stdout eof of /etc/network/ scripts
[ifupdown2.git] / debian / patches / upstream / 0001-scheduler-avoid-waiting-for-stdout-eof-of-etc-networ.patch
CommitLineData
1997a5a6
FW
1From 1303d9211d82326f7c55d56db13eed66bb1c6535 Mon Sep 17 00:00:00 2001
2From: Friedrich Weber <f.weber@proxmox.com>
3Date: Tue, 26 Sep 2023 13:33:36 +0200
4Subject: [PATCH] scheduler: avoid waiting for stdout eof of /etc/network/
5 scripts
6
7Scripts in /etc/network/ are executed using `exec_command` which
8captures stdout by default, and thus waits for stdout end-of-file via
9`Popen.communicate()`. However, this can cause hangs if the network
10script executes a long-running command in the background. Can be
11reproduced by putting the following (executable) script in
12/etc/network/if-up.d/:
13
14 #!/bin/sh
15 sleep 5&
16
17This script will cause `ifreload -a` to wait for 5 seconds per network
18interface.
19
20To avoid waiting, do not capture stdout when executing /etc/network/
21scripts. This also improves compatibility with ifupdown, which runs
22the above script in the background.
23
24Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
25---
26 ifupdown2/ifupdown/scheduler.py | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29diff --git a/ifupdown2/ifupdown/scheduler.py b/ifupdown2/ifupdown/scheduler.py
30index fda6ff2..e4d579f 100644
31--- a/ifupdown2/ifupdown/scheduler.py
32+++ b/ifupdown2/ifupdown/scheduler.py
33@@ -142,7 +142,7 @@ class ifaceScheduler():
34 for mname in ifupdownobj.script_ops.get(op, []):
35 ifupdownobj.logger.debug("%s: %s : running script %s" % (ifacename, op, mname))
36 try:
37- utils.exec_command(mname, env=command_env)
38+ utils.exec_command(mname, env=command_env, stdout=False)
39 except Exception as e:
40 if "permission denied" in str(e).lower():
41 ifupdownobj.logger.warning('%s: %s %s' % (ifacename, op, str(e)))
42--
432.39.2
44