| .. | .. |
|---|
| 113 | 113 | return args |
|---|
| 114 | 114 | |
|---|
| 115 | 115 | |
|---|
| 116 | | -def main(): |
|---|
| 116 | +def print_undefined_symbols(): |
|---|
| 117 | 117 | """Main function of this module.""" |
|---|
| 118 | 118 | args = parse_options() |
|---|
| 119 | 119 | |
|---|
| .. | .. |
|---|
| 472 | 472 | return defined, references |
|---|
| 473 | 473 | |
|---|
| 474 | 474 | |
|---|
| 475 | +def main(): |
|---|
| 476 | + try: |
|---|
| 477 | + print_undefined_symbols() |
|---|
| 478 | + except BrokenPipeError: |
|---|
| 479 | + # Python flushes standard streams on exit; redirect remaining output |
|---|
| 480 | + # to devnull to avoid another BrokenPipeError at shutdown |
|---|
| 481 | + devnull = os.open(os.devnull, os.O_WRONLY) |
|---|
| 482 | + os.dup2(devnull, sys.stdout.fileno()) |
|---|
| 483 | + sys.exit(1) # Python exits with error code 1 on EPIPE |
|---|
| 484 | + |
|---|
| 485 | + |
|---|
| 475 | 486 | if __name__ == "__main__": |
|---|
| 476 | 487 | main() |
|---|