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:
@@ -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
|
||||
|
Reference in New Issue
Block a user