From d9e8b9a3ed7b26e9cb6bb891cf0d5bb4fcd66dbf Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Tue, 20 Mar 2012 12:29:36 -0400 Subject: 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 --- ipapython/ipautil.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'ipapython/ipautil.py') diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 416ebf5f3..d3bb38ab8 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -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. -- cgit