1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

fixing: ifupdown2 (subprocesses) lives on after control-c + Parsing cmd string with shlex.split instead of string.split

Ticket: CM-9905
Reviewed By: CCR-4363
Testing Done: ^C ifupdown2 while ifreload-ing interfaces test files (~500ifaces) + smoke tests
This commit is contained in:
Julien Fortin
2016-04-10 18:55:56 +02:00
parent 74d8271b1f
commit a4a53f4b45
7 changed files with 71 additions and 9 deletions

View File

@@ -6,6 +6,9 @@
import subprocess
import ifupdownaddons
import signal
from ifupdown.utils import utils
class usercmds(ifupdownaddons.modulebase.moduleBase):
""" ifupdown2 addon module to configure user specified commands """
@@ -42,11 +45,14 @@ class usercmds(ifupdownaddons.modulebase.moduleBase):
shell=True,
stderr=subprocess.STDOUT,
close_fds=True)
utils.enable_subprocess_signal_forwarding(ch, signal.SIGINT)
cmd_returncode = ch.wait()
cmdout = ch.communicate()[0]
except Exception, e:
raise Exception('failed to execute cmd \'%s\' (%s)'
%(cmd, str(e)))
finally:
utils.disable_subprocess_signal_forwarding(signal.SIGINT)
if cmd_returncode != 0:
raise Exception(cmdout)
return cmdout