mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
scheduler: avoid waiting for stdout eof of /etc/network/ scripts
Scripts in /etc/network/ are executed using `exec_command` which captures stdout by default, and thus waits for stdout end-of-file via `Popen.communicate()`. However, this can cause hangs if the network script executes a long-running command in the background. Can be reproduced by putting the following (executable) script in /etc/network/if-up.d/: #!/bin/sh sleep 5& This script will cause `ifreload -a` to wait for 5 seconds per network interface. To avoid waiting, do not capture stdout when executing /etc/network/ scripts. This also improves compatibility with ifupdown, which runs the above script in the background. Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
This commit is contained in:
@ -142,7 +142,7 @@ class ifaceScheduler():
|
||||
for mname in ifupdownobj.script_ops.get(op, []):
|
||||
ifupdownobj.logger.debug("%s: %s : running script %s" % (ifacename, op, mname))
|
||||
try:
|
||||
utils.exec_command(mname, env=command_env)
|
||||
utils.exec_command(mname, env=command_env, stdout=False)
|
||||
except Exception as e:
|
||||
if "permission denied" in str(e).lower():
|
||||
ifupdownobj.logger.warning('%s: %s %s' % (ifacename, op, str(e)))
|
||||
|
Reference in New Issue
Block a user