Skip to content

Commit

Permalink
#4393 failure to redirect should not propagate
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 29, 2024
1 parent adc0487 commit ee8827a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xpra/util/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit ee8827a

Please sign in to comment.