aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2010-07-07 21:40:51 +0200
committerSebastian Pipping <sebastian@pipping.org>2010-07-07 21:43:45 +0200
commita2cc62702fb5d6b54aa68c4a4ed2bf300e582b31 (patch)
tree532760b1a1b28c739ebafc95e6a0d1b690f89d4f
parentReplace os.system() by subprocess.Popen() (diff)
downloadlayman-a2cc62702fb5d6b54aa68c4a4ed2bf300e582b31.tar.gz
layman-a2cc62702fb5d6b54aa68c4a4ed2bf300e582b31.tar.bz2
layman-a2cc62702fb5d6b54aa68c4a4ed2bf300e582b31.zip
Close stdin of child processes in quiet mode
-rw-r--r--CHANGES3
-rw-r--r--doc/layman.8.xml13
-rw-r--r--layman/overlays/source.py14
3 files changed, 22 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index 10b4371..707c171 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,9 @@ Version TODO
- Replace os.system() by subprocess.Popen()
+ - Close stdin of child processes when run in quiet mode
+ to avoid running into infinite and blindly interactive sessions.
+
Version 1.3.4 - Released 2010-07-05
===================================
diff --git a/doc/layman.8.xml b/doc/layman.8.xml
index 0988ff4..ccd127e 100644
--- a/doc/layman.8.xml
+++ b/doc/layman.8.xml
@@ -482,12 +482,13 @@
<term><option>--quiet</option></term>
<listitem>
<para>Makes <command>layman</command> completely quiet.
- This option is dangerous: If the processes spawned by
- layman when adding or synchronizing overlays require
- any input layman will hang without telling you
- why. This might happen for example if your overlay
- resides in subversion and the SSL certificate of
- the server needs acceptance.</para>
+ In quiet mode child processes will be run with stdin closed
+ to avoid running into infinite and blindly interactive sessions.
+ Thus a child process may abort once it runs into an
+ situation with need for human interaction.
+ For example this might happen if your overlay
+ resides in Subversion and the SSL certificate of
+ the server needs manual acceptance.</para>
</listitem>
</varlistentry>
diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 621cf4c..9836526 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -130,20 +130,30 @@ class OverlaySource(object):
OUT.info('Running... # %s' % command_repr, 2)
if self.quiet:
+ input_source = subprocess.PIPE
output_target = open('/dev/null', 'w')
else:
- output_target = None # i.e. re-use parent file descriptors
+ # Re-use parent file descriptors
+ input_source = None
+ output_target = None
proc = subprocess.Popen(args,
+ stdin=input_source,
stdout=output_target,
stderr=output_target,
cwd=cwd,
env=env)
if self.quiet:
+ # Make child non-interactive
+ proc.stdin.close()
+
+ result = proc.wait()
+
+ if self.quiet:
output_target.close()
- return proc.wait()
+ return result
def to_xml_hook(self, repo_elem):
pass