diff options
author | Junius Gao <Junius.Gao@veritas.com> | 2022-10-27 10:58:18 +0800 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2023-01-16 09:45:56 -0500 |
commit | c01b85af05db437275d3ef40810a40ab31b05033 (patch) | |
tree | a27bfb739fb9e4236accdb7eb44d994494304583 | |
parent | 131b3bcf5691a158598bed30bd0af6ac9c96737c (diff) | |
download | sos-c01b85af05db437275d3ef40810a40ab31b05033.tar.gz |
[utilities] Enhance timeout mechanism
Enhance on timeout mechanism. Force the parent process to exit when
it has a deadlock child.
Signed-off-by: Junius Gao <Junius.Gao@veritas.com>
-rwxr-xr-x | bin/sos | 1 | ||||
-rw-r--r-- | sos/utilities.py | 3 |
2 files changed, 3 insertions, 1 deletions
@@ -20,5 +20,6 @@ except KeyboardInterrupt: if __name__ == '__main__': sos = SoS(sys.argv[1:]) sos.execute() + os._exit(0) # vim:ts=4 et sw=4 diff --git a/sos/utilities.py b/sos/utilities.py index cefaa307..4556632a 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -176,7 +176,7 @@ def sos_get_command_output(command, timeout=TIMEOUT_DEFAULT, stderr=False, os.chdir(chdir) def _check_poller(proc): - if poller(): + if poller() or proc.poll() == 124: proc.terminate() raise SoSTimeoutError time.sleep(0.01) @@ -240,6 +240,7 @@ def sos_get_command_output(command, timeout=TIMEOUT_DEFAULT, stderr=False, _output.close() # until we separate timeouts from the `timeout` command # handle per-cmd timeouts via Plugin status checks + reader.running = False return {'status': 124, 'output': reader.get_contents(), 'truncated': reader.is_full} if to_file: |