[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH 3/3] Don't leak fds (#520154)
- From: Joel Granados Moreno <jgranado redhat com>
- To: anaconda-devel-list redhat com
- Subject: [PATCH 3/3] Don't leak fds (#520154)
- Date: Thu, 17 Sep 2009 14:43:19 +0200
---
iutil.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/iutil.py b/iutil.py
index 1f2c982..3422009 100644
--- a/iutil.py
+++ b/iutil.py
@@ -82,6 +82,8 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
if not searchPath and not os.access (command, os.X_OK):
raise RuntimeError, command + " can not be run"
+ stdinclose = stdoutclose = stderrclose = lambda : None
+
argv = list(argv)
if isinstance(stdin, str):
if os.access(stdin, os.R_OK):
@@ -149,6 +151,9 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
proc_err.join()
del proc_err
+ stdinclose()
+ stdoutclose()
+ stderrclose()
except OSError as e:
errstr = "Error running %s: %s" % (command, e.strerror)
log.error(errstr)
@@ -158,6 +163,10 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
os.close(perrin)
proc_std.join()
proc_err.join()
+
+ stdinclose()
+ stdoutclose()
+ stderrclose()
raise RuntimeError, errstr
return ret
--
1.6.4.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]