Skip to content

Commit

Permalink
ignores the BrokenPipeError
Browse files Browse the repository at this point in the history
  • Loading branch information
christophkloeffel committed Sep 11, 2024
1 parent a94ef14 commit 1d5d9c2
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions trlc/trlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@
# You should have received a copy of the GNU General Public License
# along with TRLC. If not, see <https://www.gnu.org/licenses/>.

import re
import os
import sys
import json
import argparse
import json
import os
import re
import subprocess
import sys
from fractions import Fraction

from trlc import ast
from trlc import lint
from trlc.errors import TRLC_Error, Location, Message_Handler, Kind
from trlc.parser import Parser
from trlc import ast, lint
from trlc.errors import Kind, Location, Message_Handler, TRLC_Error
from trlc.lexer import Token_Stream
from trlc.version import TRLC_VERSION, BUGS_URL
from trlc.parser import Parser
from trlc.version import BUGS_URL, TRLC_VERSION

# pylint: disable=unused-import
try:
Expand Down Expand Up @@ -551,7 +550,7 @@ def process(self):
return self.stab


def main():
def trlc():
ap = argparse.ArgumentParser(
prog="trlc",
description="TRLC %s (Python reference implementation)" % TRLC_VERSION,
Expand Down Expand Up @@ -821,5 +820,16 @@ def get_status(parser):
return 1


def main():
try:
return trlc()
except BrokenPipeError:
# Python flushes standard streams on exit; redirect remaining output
# to devnull to avoid another BrokenPipeError at shutdown
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())
return 141


if __name__ == "__main__":
sys.exit(main())

0 comments on commit 1d5d9c2

Please sign in to comment.