Skip to content

Commit

Permalink
Merge branch 'clean_exit_on_broken_pipe'
Browse files Browse the repository at this point in the history
  • Loading branch information
piax93 committed Nov 16, 2020
2 parents b8e2a38 + 66a37eb commit fa47076
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pidtree_bcc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def probe_watchdog(probe_workers: List[Process]):


def main(args: argparse.Namespace):
global EXIT_CODE
probe_workers = []
logging.basicConfig(stream=sys.stderr, level=logging.INFO)
curried_handler = partial(termination_handler, probe_workers, os.getpid())
Expand Down Expand Up @@ -131,12 +132,11 @@ def main(args: argparse.Namespace):
out.flush()
except Exception as e:
# Terminate everything if something goes wrong
EXIT_CODE = 1
logging.error('Encountered unexpected error: {}'.format(e))
for worker in probe_workers:
worker.terminate()
sys.exit(1)
finally:
out.close()
sys.exit(EXIT_CODE)


if __name__ == '__main__':
Expand Down

0 comments on commit fa47076

Please sign in to comment.