mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
fail2ban-regex: don't error by output if stdout pipe gets closed (e. g. using together with head);
amend to gh-2758 (see gh-3653)
This commit is contained in:
parent
7523a777f0
commit
c6244a8509
1 changed files with 8 additions and 0 deletions
|
|
@ -789,7 +789,15 @@ class Fail2banRegex(object):
|
|||
return True
|
||||
|
||||
|
||||
def _loc_except_hook(exctype, value, traceback):
|
||||
if (exctype != BrokenPipeError and exctype != IOError or value.errno != 32):
|
||||
return sys.__excepthook__(exctype, value, traceback)
|
||||
# pipe seems to be closed (head / tail / etc), thus simply exit:
|
||||
sys.exit(0)
|
||||
|
||||
def exec_command_line(*args):
|
||||
sys.excepthook = _loc_except_hook; # stop on closed/broken pipe
|
||||
|
||||
logging.exitOnIOError = True
|
||||
parser = get_opt_parser()
|
||||
(opts, args) = parser.parse_args(*args)
|
||||
|
|
|
|||
Loading…
Reference in a new issue