From 954ba580b66ceec3cbf593fb6f06c3ed278ab0e0 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Mon, 24 Feb 2014 14:46:52 +0100 Subject: [PATCH] [crans_utils] process_status sans utiliser subprocess --- crans_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crans_utils.py b/crans_utils.py index ec91028..64ae861 100644 --- a/crans_utils.py +++ b/crans_utils.py @@ -216,11 +216,11 @@ def process_status(pid): """ Vérifie l'état du processus pid """ - cmd = subprocess.call(['ps', '%s' % pid], stdout=DEVNULL, stderr=subprocess.STDOUT) - if cmd != 0: - return False - else: + try: + os.getpgid(int(pid)) return True + except OSError: + return False def escape(chaine): """Renvoie une chaîne échapée pour pouvoir la mettre en toute sécurité