From c5ffb08ed7a0c8206782d613c4f309cfbbe7e699 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 20 Aug 2024 17:36:02 -0400 Subject: [PATCH] fix: give detailed error message when ps is not installed (#482) ## Summary by CodeRabbit - **New Features** - Added a command-line check to ensure the availability of the `ps` command before executing the main logic of the status check, enhancing system stability and preventing runtime errors. - **Bug Fixes** - Improved error handling by outputting a descriptive message when the `ps` command is not found, allowing users to understand the issue clearly. --------- Signed-off-by: Jinzhe Zeng --- dpdispatcher/machines/shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dpdispatcher/machines/shell.py b/dpdispatcher/machines/shell.py index e2bdc368..6d825f4f 100644 --- a/dpdispatcher/machines/shell.py +++ b/dpdispatcher/machines/shell.py @@ -74,6 +74,7 @@ def check_status(self, job): # mark defunct process as terminated ret, stdin, stdout, stderr = self.context.block_call( + r"""command -v ps >/dev/null 2>&1 || { echo >&2 "I require ps but it's not installed. Aborting."; exit 1; };""" f"if ps -p {job_id} > /dev/null && ! (ps -o command -p {job_id} | grep defunct >/dev/null) ; then echo 1; fi" ) if ret != 0: