mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-11 00:31:56 -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)
|
||||
|
||||
def sigterm_handler(signum, frame):
|
||||
print_info("\nCleaning up...")
|
||||
|
||||
global RESPONDERS
|
||||
clean_responders(RESPONDERS)
|
||||
|
||||
sys.exit(1)
|
||||
# do what SIGINT does (raise a KeyboardInterrupt)
|
||||
sigint_handler = signal.getsignal(signal.SIGINT)
|
||||
if callable(sigint_handler):
|
||||
sigint_handler(signum, frame)
|
||||
|
||||
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")
|
||||
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
signal.signal(signal.SIGINT, sigterm_handler)
|
||||
|
||||
required_ports = BASE_PORTS
|
||||
if options.check_ca:
|
||||
@ -384,6 +381,7 @@ if __name__ == "__main__":
|
||||
except SystemExit, e:
|
||||
sys.exit(e)
|
||||
except KeyboardInterrupt:
|
||||
print_info("\nCleaning up...")
|
||||
sys.exit(1)
|
||||
except RuntimeError, e:
|
||||
sys.exit(e)
|
||||
@ -395,4 +393,3 @@ if __name__ == "__main__":
|
||||
os.remove(file_name)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -26,7 +26,6 @@ IPA_BASEDN_INFO = 'ipa v2.0'
|
||||
|
||||
import string
|
||||
import tempfile
|
||||
from ipapython.ipa_log_manager import *
|
||||
import subprocess
|
||||
import random
|
||||
import os, sys, traceback, readline
|
||||
@ -37,14 +36,14 @@ import urllib2
|
||||
import socket
|
||||
import ldap
|
||||
import struct
|
||||
|
||||
from ipapython import ipavalidate
|
||||
from types import *
|
||||
|
||||
import re
|
||||
import xmlrpclib
|
||||
import datetime
|
||||
import netaddr
|
||||
|
||||
from ipapython.ipa_log_manager import *
|
||||
from ipapython import ipavalidate
|
||||
from ipapython import config
|
||||
try:
|
||||
from subprocess import CalledProcessError
|
||||
@ -259,10 +258,14 @@ def run(args, stdin=None, raiseonerr=True,
|
||||
p_out = subprocess.PIPE
|
||||
p_err = subprocess.PIPE
|
||||
|
||||
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err,
|
||||
close_fds=True, env=env)
|
||||
stdout,stderr = p.communicate(stdin)
|
||||
stdout,stderr = str(stdout), str(stderr) # Make pylint happy
|
||||
try:
|
||||
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err,
|
||||
close_fds=True, env=env)
|
||||
stdout,stderr = p.communicate(stdin)
|
||||
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
|
||||
# to log. Run through the nolog items.
|
||||
|
Loading…
Reference in New Issue
Block a user