[3.8] bpo-39828: Fix json.tool to catch BrokenPipeError (GH-18779). (GH-18894)



(cherry picked from commit 700cb587303461d5a96456c56902cfdd8ad50e2d)

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>

Automerge-Triggered-By: @vstinner
diff --git a/Lib/json/tool.py b/Lib/json/tool.py
index 8db9ea4..c42138a 100644
--- a/Lib/json/tool.py
+++ b/Lib/json/tool.py
@@ -52,4 +52,7 @@
 
 
 if __name__ == '__main__':
-    main()
+    try:
+        main()
+    except BrokenPipeError as exc:
+        sys.exit(exc.errno)