]>
Commit | Line | Data |
---|---|---|
1997a5a6 FW |
1 | From 1303d9211d82326f7c55d56db13eed66bb1c6535 Mon Sep 17 00:00:00 2001 |
2 | From: Friedrich Weber <f.weber@proxmox.com> | |
3 | Date: Tue, 26 Sep 2023 13:33:36 +0200 | |
4 | Subject: [PATCH] scheduler: avoid waiting for stdout eof of /etc/network/ | |
5 | scripts | |
6 | ||
7 | Scripts in /etc/network/ are executed using `exec_command` which | |
8 | captures stdout by default, and thus waits for stdout end-of-file via | |
9 | `Popen.communicate()`. However, this can cause hangs if the network | |
10 | script executes a long-running command in the background. Can be | |
11 | reproduced by putting the following (executable) script in | |
12 | /etc/network/if-up.d/: | |
13 | ||
14 | #!/bin/sh | |
15 | sleep 5& | |
16 | ||
17 | This script will cause `ifreload -a` to wait for 5 seconds per network | |
18 | interface. | |
19 | ||
20 | To avoid waiting, do not capture stdout when executing /etc/network/ | |
21 | scripts. This also improves compatibility with ifupdown, which runs | |
22 | the above script in the background. | |
23 | ||
24 | Signed-off-by: Friedrich Weber <f.weber@proxmox.com> | |
25 | --- | |
26 | ifupdown2/ifupdown/scheduler.py | 2 +- | |
27 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
28 | ||
29 | diff --git a/ifupdown2/ifupdown/scheduler.py b/ifupdown2/ifupdown/scheduler.py | |
30 | index 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 | -- | |
43 | 2.39.2 | |
44 |