Merge pull request #54 from chenxiaolong/epipe

avbroot/ota.py: Fix EPIPE when interrupted by controlling TTY
This commit is contained in:
Andrew Gunnerson
2023-02-15 18:48:44 -05:00
committed by GitHub
+11
View File
@@ -664,6 +664,16 @@ def open_signing_wrapper(f, privkey, passphrase, cert):
'''
with openssl.inject_passphrase(passphrase):
session_kwargs = {}
if os.name != 'nt':
# We don't want the controlling terminal to interrupt openssl on
# ^C or ^\. That'll cause _TeeFileDescriptor's writes to the stdin
# pipe to fail, and certain classes, like ZipFile, will write to
# the fd in their __exit__ methods. This causes a BrokenPipeError
# to be raised while the existing KeyboardInterrupt is being
# propagated up. We'll handling killing openssl ourselves.
session_kwargs['start_new_session'] = True
process = subprocess.Popen(
[
'openssl',
@@ -679,6 +689,7 @@ def open_signing_wrapper(f, privkey, passphrase, cert):
],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
**session_kwargs,
)
try: