mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Wait for child process to terminate after receiving SIGINT in ipautil.run.
Do cleanup on KeyboardInterrupt rather than in custom SIGINT handler in ipa-replica-conncheck. https://fedorahosted.org/freeipa/ticket/2127
This commit is contained in:
parent
f6077c46b3
commit
d9e8b9a3ed
@ -158,12 +158,10 @@ def clean_responders(responders):
|
|||||||
responders.remove(responder)
|
responders.remove(responder)
|
||||||
|
|
||||||
def sigterm_handler(signum, frame):
|
def sigterm_handler(signum, frame):
|
||||||
print_info("\nCleaning up...")
|
# do what SIGINT does (raise a KeyboardInterrupt)
|
||||||
|
sigint_handler = signal.getsignal(signal.SIGINT)
|
||||||
global RESPONDERS
|
if callable(sigint_handler):
|
||||||
clean_responders(RESPONDERS)
|
sigint_handler(signum, frame)
|
||||||
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def configure_krb5_conf(realm, kdc, filename):
|
def configure_krb5_conf(realm, kdc, filename):
|
||||||
|
|
||||||
@ -268,7 +266,6 @@ def main():
|
|||||||
root_logger.debug("missing options might be asked for interactively later\n")
|
root_logger.debug("missing options might be asked for interactively later\n")
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||||
signal.signal(signal.SIGINT, sigterm_handler)
|
|
||||||
|
|
||||||
required_ports = BASE_PORTS
|
required_ports = BASE_PORTS
|
||||||
if options.check_ca:
|
if options.check_ca:
|
||||||
@ -384,6 +381,7 @@ if __name__ == "__main__":
|
|||||||
except SystemExit, e:
|
except SystemExit, e:
|
||||||
sys.exit(e)
|
sys.exit(e)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
print_info("\nCleaning up...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except RuntimeError, e:
|
except RuntimeError, e:
|
||||||
sys.exit(e)
|
sys.exit(e)
|
||||||
@ -395,4 +393,3 @@ if __name__ == "__main__":
|
|||||||
os.remove(file_name)
|
os.remove(file_name)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ IPA_BASEDN_INFO = 'ipa v2.0'
|
|||||||
|
|
||||||
import string
|
import string
|
||||||
import tempfile
|
import tempfile
|
||||||
from ipapython.ipa_log_manager import *
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import random
|
import random
|
||||||
import os, sys, traceback, readline
|
import os, sys, traceback, readline
|
||||||
@ -37,14 +36,14 @@ import urllib2
|
|||||||
import socket
|
import socket
|
||||||
import ldap
|
import ldap
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from ipapython import ipavalidate
|
|
||||||
from types import *
|
from types import *
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import datetime
|
import datetime
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
|
from ipapython.ipa_log_manager import *
|
||||||
|
from ipapython import ipavalidate
|
||||||
from ipapython import config
|
from ipapython import config
|
||||||
try:
|
try:
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
@ -259,10 +258,14 @@ def run(args, stdin=None, raiseonerr=True,
|
|||||||
p_out = subprocess.PIPE
|
p_out = subprocess.PIPE
|
||||||
p_err = subprocess.PIPE
|
p_err = subprocess.PIPE
|
||||||
|
|
||||||
|
try:
|
||||||
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err,
|
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err,
|
||||||
close_fds=True, env=env)
|
close_fds=True, env=env)
|
||||||
stdout,stderr = p.communicate(stdin)
|
stdout,stderr = p.communicate(stdin)
|
||||||
stdout,stderr = str(stdout), str(stderr) # Make pylint happy
|
stdout,stderr = str(stdout), str(stderr) # Make pylint happy
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
p.wait()
|
||||||
|
raise
|
||||||
|
|
||||||
# The command and its output may include passwords that we don't want
|
# The command and its output may include passwords that we don't want
|
||||||
# to log. Run through the nolog items.
|
# to log. Run through the nolog items.
|
||||||
|
Loading…
Reference in New Issue
Block a user