summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2016-10-07 13:46:59 -0500
committerTony Asleson <tasleson@redhat.com>2016-10-10 16:31:00 -0500
commit9f0195ec1ec1113695abdb1ada82dc138bc7488b (patch)
treec3569e1a6362282322db18ba3a41929902c0a2ee
parent2e941beb446e71a9278e38eb4d69e19dc4b284f8 (diff)
downloadlvm2-9f0195ec1ec1113695abdb1ada82dc138bc7488b.tar.gz
lvmdbusd: Ensure tmp dir gets cleaned up
Regardless of the outcome of starting up the lvm shell process, lets ensure we clean up the temp directory and pipe.
-rwxr-xr-xdaemons/lvmdbusd/lvm_shell_proxy.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py b/daemons/lvmdbusd/lvm_shell_proxy.py
index e6154888e..6e6d52aab 100755
--- a/daemons/lvmdbusd/lvm_shell_proxy.py
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py
@@ -129,20 +129,24 @@ class LVMShellProxy(object):
[LVM_CMD + " 32>%s" % tmp_file],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=local_env,
stderr=subprocess.PIPE, close_fds=True, shell=True)
- flags = fcntl(self.lvm_shell.stdout, F_GETFL)
- fcntl(self.lvm_shell.stdout, F_SETFL, flags | os.O_NONBLOCK)
- flags = fcntl(self.lvm_shell.stderr, F_GETFL)
- fcntl(self.lvm_shell.stderr, F_SETFL, flags | os.O_NONBLOCK)
-
- # wait for the first prompt
- errors = self._read_until_prompt()[2]
- if errors and len(errors):
- raise RuntimeError(errors)
-
- # These will get deleted when the FD count goes to zero so we can be
- # sure to clean up correctly no matter how we finish
- os.unlink(tmp_file)
- os.rmdir(tmp_dir)
+
+ try:
+ flags = fcntl(self.lvm_shell.stdout, F_GETFL)
+ fcntl(self.lvm_shell.stdout, F_SETFL, flags | os.O_NONBLOCK)
+ flags = fcntl(self.lvm_shell.stderr, F_GETFL)
+ fcntl(self.lvm_shell.stderr, F_SETFL, flags | os.O_NONBLOCK)
+
+ # wait for the first prompt
+ errors = self._read_until_prompt()[2]
+ if errors and len(errors):
+ raise RuntimeError(errors)
+ except:
+ raise
+ finally:
+ # These will get deleted when the FD count goes to zero so we can be
+ # sure to clean up correctly no matter how we finish
+ os.unlink(tmp_file)
+ os.rmdir(tmp_dir)
def get_error_msg(self):
# We got an error, lets go fetch the error message