mirror of https://github.com/fail2ban/fail2ban
`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)pull/3381/head
parent
7523a777f0
commit
c6244a8509
|
@ -789,7 +789,15 @@ class Fail2banRegex(object):
|
||||||
return True
|
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):
|
def exec_command_line(*args):
|
||||||
|
sys.excepthook = _loc_except_hook; # stop on closed/broken pipe
|
||||||
|
|
||||||
logging.exitOnIOError = True
|
logging.exitOnIOError = True
|
||||||
parser = get_opt_parser()
|
parser = get_opt_parser()
|
||||||
(opts, args) = parser.parse_args(*args)
|
(opts, args) = parser.parse_args(*args)
|
||||||
|
|
Loading…
Reference in New Issue