summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2016-04-27 10:45:15 (GMT)
committerMartin Pitt <martin.pitt@ubuntu.com>2016-04-27 10:45:15 (GMT)
commitc13bab9fbd8ec1eef7e48a10c4401568eb467c1a (patch)
tree2a3f7cf36036cf8ae4a3ed4f2d676da1b95c1338
parente10e32119bca12dbf40f9fe7015b7fa71fbc48e8 (diff)
Fix OSError when running a shell is requested but /dev/tty does not exist
Just log an error instead.
-rw-r--r--debian/changelog7
-rw-r--r--lib/VirtSubproc.py13
2 files changed, 15 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index 149c021..49b299f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+autopkgtest (3.20.6) UNRELEASED; urgency=medium
+
+ * Fix OSError when running a shell is requested but /dev/tty does not exist;
+ just log an error instead.
+
+ -- Martin Pitt <mpitt@debian.org> Wed, 27 Apr 2016 12:44:42 +0200
+
autopkgtest (3.20.5) unstable; urgency=medium
[ Martin Packman ]
diff --git a/lib/VirtSubproc.py b/lib/VirtSubproc.py
index ef8a4b8..02c3187 100644
--- a/lib/VirtSubproc.py
+++ b/lib/VirtSubproc.py
@@ -602,11 +602,14 @@ def cmd_shell(c, ce):
except KeyError:
pass
cmd += 'bash -i'
- with open('/dev/tty', 'rb') as sin:
- with open('/dev/tty', 'wb') as sout:
- with open('/dev/tty', 'wb') as serr:
- subprocess.call(auxverb + ['sh', '-c', cmd],
- stdin=sin, stdout=sout, stderr=serr)
+ try:
+ with open('/dev/tty', 'rb') as sin:
+ with open('/dev/tty', 'wb') as sout:
+ with open('/dev/tty', 'wb') as serr:
+ subprocess.call(auxverb + ['sh', '-c', cmd],
+ stdin=sin, stdout=sout, stderr=serr)
+ except (OSError, IOError) as e:
+ adtlog.error('Cannot run shell: %s' % e)
def command():