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:
@@ -11,8 +11,13 @@ import logging
|
||||
import subprocess
|
||||
import re
|
||||
import os
|
||||
from iface import *
|
||||
import rtnetlink_api as rtnetlink_api
|
||||
import signal
|
||||
import shlex
|
||||
|
||||
from iface import *
|
||||
from ifupdown.utils import utils
|
||||
|
||||
|
||||
class ifupdownBase(object):
|
||||
|
||||
@@ -24,19 +29,22 @@ class ifupdownBase(object):
|
||||
cmd_returncode = 0
|
||||
cmdout = ''
|
||||
try:
|
||||
self.logger.info('Executing ' + cmd)
|
||||
self.logger.info('executing ' + cmd)
|
||||
if self.DRYRUN:
|
||||
return cmdout
|
||||
ch = subprocess.Popen(cmd.split(),
|
||||
ch = subprocess.Popen(shlex.split(cmd),
|
||||
stdout=subprocess.PIPE,
|
||||
shell=False, env=cmdenv,
|
||||
stderr=subprocess.STDOUT,
|
||||
close_fds=True)
|
||||
utils.enable_subprocess_signal_forwarding(ch, signal.SIGINT)
|
||||
cmdout = ch.communicate()[0]
|
||||
cmd_returncode = ch.wait()
|
||||
except OSError, e:
|
||||
raise Exception('could not execute ' + cmd +
|
||||
'(' + str(e) + ')')
|
||||
finally:
|
||||
utils.disable_subprocess_signal_forwarding(signal.SIGINT)
|
||||
if cmd_returncode != 0:
|
||||
raise Exception('error executing cmd \'%s\'' %cmd +
|
||||
'\n(' + cmdout.strip('\n ') + ')')
|
||||
|
||||
Reference in New Issue
Block a user