diff --git a/fail2ban/server/utils.py b/fail2ban/server/utils.py index 262b303d..45d1c09d 100644 --- a/fail2ban/server/utils.py +++ b/fail2ban/server/utils.py @@ -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: diff --git a/fail2ban/tests/actiontestcase.py b/fail2ban/tests/actiontestcase.py index 8c9b5ef1..6d8fcc82 100644 --- a/fail2ban/tests/actiontestcase.py +++ b/fail2ban/tests/actiontestcase.py @@ -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')