glasgow: terminate when stdout is closed

Otherwise, it would keep attempting to write to stdout after the parent process had died, and cause a mess.
This commit is contained in:
Sebastien Bourdeauducq 2019-10-24 15:56:57 +08:00
parent aa68df8fcc
commit 28745b9dae

View File

@ -32,10 +32,10 @@ index 35b8960..3f37b9f 100644
+from .logic import LogicApplet +from .logic import LogicApplet
diff --git a/software/glasgow/applet/logic.py b/software/glasgow/applet/logic.py diff --git a/software/glasgow/applet/logic.py b/software/glasgow/applet/logic.py
new file mode 100644 new file mode 100644
index 0000000..c58de0b index 0000000..3af2843
--- /dev/null --- /dev/null
+++ b/software/glasgow/applet/logic.py +++ b/software/glasgow/applet/logic.py
@@ -0,0 +1,92 @@ @@ -0,0 +1,94 @@
+import sys +import sys
+import logging +import logging
+import os +import os
@ -121,6 +121,8 @@ index 0000000..c58de0b
+ while True: + while True:
+ data = await iface.read(65536) + data = await iface.read(65536)
+ output_stream.write(data) + output_stream.write(data)
+ if output_stream.is_closing():
+ raise SystemExit("glasgow: stdout closed")
+ +
+# ------------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------------------------
+ +