summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2012-03-20 12:29:36 -0400
committerMartin Kosek <mkosek@redhat.com>2012-03-23 10:53:02 +0100
commitd9e8b9a3ed7b26e9cb6bb891cf0d5bb4fcd66dbf (patch)
treea55bf72fe14cfb8bd0bacb4088c7335603220c2b /ipapython
parentf6077c46b373cdd9dbc1c7618d067921df0cedb0 (diff)
downloadfreeipa-d9e8b9a3ed7b26e9cb6bb891cf0d5bb4fcd66dbf.tar.gz
freeipa-d9e8b9a3ed7b26e9cb6bb891cf0d5bb4fcd66dbf.tar.xz
freeipa-d9e8b9a3ed7b26e9cb6bb891cf0d5bb4fcd66dbf.zip
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
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py19
1 files changed, 11 insertions, 8 deletions
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.