From ee8827a44cad3a2a0e2d171c85979b3d9e425dc7 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 29 Oct 2024 15:37:30 +0700 Subject: [PATCH] #4393 failure to redirect should not propagate --- xpra/util/io.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xpra/util/io.py b/xpra/util/io.py index c3f763e34e..420ab07b4a 100644 --- a/xpra/util/io.py +++ b/xpra/util/io.py @@ -128,7 +128,10 @@ def __enter__(self): self.tmp = NamedTemporaryFile(prefix="stderr") fd = self.tmp.fileno() os.dup2(fd, 2) - sys.stderr = os.fdopen(self.savedstderr, "w") + try: + sys.stderr = os.fdopen(self.savedstderr, "w") + except OSError as e: + noerr(sys.stderr.write, f"failed to replace stderr: {e}\n") def __exit__(self, *_args): try: @@ -137,7 +140,7 @@ def __exit__(self, *_args): self.stderr = os.read(fd, 32768) self.tmp.close() except OSError as e: - noerr(sys.stderr.write, f"oops: {e}\n") + noerr(sys.stderr.write, f"failed to restore stderr: {e}\n") if self.savedstderr is not None: os.dup2(self.savedstderr, 2)