Skip to content

Commit dc996f8

Browse files
committed
Wait until xmlsec program completes to avoid zombies
Popen was often used to execute the xmlsec program without calling wait() on the process file handler, which resulted in zombies being left for arbitrary time (depending on gc). Adding the wait() call as implemented by this fix should not cause any delays nor deadlocks since it is always run only after the program finishes - after stdout and stderr are read. It should thus not cause any regressions. For more info about Popen causing zombies, please see: http://stackoverflow.com/questions/2760652/how-to-kill-or-avoid-zombie-processes-with-subprocess-module https://lbolla.info/blog/2014/01/23/die-zombie-die
1 parent 24f141c commit dc996f8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/saml2/algsupport.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def get_algorithm_support(xmlsec):
3939

4040
p_out = pof.stdout.read().decode('utf-8')
4141
p_err = pof.stderr.read().decode('utf-8')
42+
pof.wait()
4243

4344
if not p_err:
4445
p = p_out.split('\n')
@@ -73,4 +74,4 @@ def algorithm_support_in_metadata(xmlsec):
7374
res = get_algorithm_support(xmlsec)
7475
print(res)
7576
for a in algorithm_support_in_metadata(xmlsec):
76-
print(a)
77+
print(a)

src/saml2/sigver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ def version(self):
797797
com_list = [self.xmlsec, "--version"]
798798
pof = Popen(com_list, stderr=PIPE, stdout=PIPE)
799799
content = pof.stdout.read().decode('ascii')
800+
pof.wait()
800801
try:
801802
return content.split(" ")[1]
802803
except IndexError:
@@ -990,6 +991,7 @@ def _run_xmlsec(self, com_list, extra_args, validate_output=True,
990991

991992
p_out = pof.stdout.read().decode('utf-8')
992993
p_err = pof.stderr.read().decode('utf-8')
994+
pof.wait()
993995

994996
if pof.returncode is not None and pof.returncode < 0:
995997
logger.error(LOG_LINE, p_out, p_err)

0 commit comments

Comments
 (0)