mirror of https://github.com/fail2ban/fail2ban
1) prevents a bug by logging stdout/stderr if retcode still None:
``` in executeCmd if retcode < 0: TypeError: unorderable types: NoneType() < int() ``` 2) prevents a rarely test case bug of testExecuteTimeoutWithNastyChildren, because no stdout (Resource temporarily unavailable), possible no flush by IO of the killing process;pull/1346/head
parent
6406f6f560
commit
935d79eaae
|
@ -159,7 +159,7 @@ class Utils():
|
|||
# if was timeouted (killed/terminated) - to prevent waiting, set std handles to non-blocking mode.
|
||||
if popen.stdout:
|
||||
try:
|
||||
if retcode < 0:
|
||||
if retcode is None or retcode < 0:
|
||||
Utils.setFBlockMode(popen.stdout, False)
|
||||
stdout = popen.stdout.read()
|
||||
except IOError as e:
|
||||
|
@ -169,7 +169,7 @@ class Utils():
|
|||
popen.stdout.close()
|
||||
if popen.stderr:
|
||||
try:
|
||||
if retcode < 0:
|
||||
if retcode is None or retcode < 0:
|
||||
Utils.setFBlockMode(popen.stderr, False)
|
||||
stderr = popen.stderr.read()
|
||||
except IOError as e:
|
||||
|
|
|
@ -247,7 +247,7 @@ class CommandActionTest(LogCaptureTestCase):
|
|||
cpid = getnastypid()
|
||||
# Verify that the process itself got killed
|
||||
self.assertTrue(Utils.wait_for(lambda: not pid_exists(cpid), 3)) # process should have been killed
|
||||
self.assertLogged('my pid ')
|
||||
self.assertLogged('my pid ', 'Resource temporarily unavailable')
|
||||
self.assertLogged('timed out')
|
||||
self.assertLogged('killed with SIGTERM',
|
||||
'killed with SIGKILL')
|
||||
|
@ -261,7 +261,7 @@ class CommandActionTest(LogCaptureTestCase):
|
|||
cpid = getnastypid()
|
||||
# Verify that the process itself got killed
|
||||
self.assertTrue(Utils.wait_for(lambda: not pid_exists(cpid), 3))
|
||||
self.assertLogged('my pid ')
|
||||
self.assertLogged('my pid ', 'Resource temporarily unavailable')
|
||||
self.assertLogged('timed out')
|
||||
self.assertLogged('killed with SIGTERM',
|
||||
'killed with SIGKILL')
|
||||
|
|
Loading…
Reference in New Issue