From c0500712c6b4b3c2b17fccbf7a2d1f286b36eb08 Mon Sep 17 00:00:00 2001
From: Mark Grondona <mgrondona@llnl.gov>
Date: Wed, 11 Jun 2003 18:15:00 +0000
Subject: [PATCH]  o use kill(-pgid, 0) to determine if job's session is still
 running.

---
 src/slurmd/shm.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/slurmd/shm.c b/src/slurmd/shm.c
index f79fb59b7bc..2a1753def11 100644
--- a/src/slurmd/shm.c
+++ b/src/slurmd/shm.c
@@ -244,22 +244,18 @@ shm_step_still_running(uint32_t jobid, uint32_t stepid)
 	bool        retval = false;
 	int         i;
 	job_step_t *s;
-	task_t     *t;
 
 	xassert(slurmd_shm != NULL);
 
 	_shm_lock();
 	if ((i = _shm_find_step(jobid, stepid)) >= 0) {
 		s = &slurmd_shm->step[i];
-		for (t = _taskp(s->task_list); t; t = _taskp(t->next)) {
-			/* If at least one task still remains, consider
-			 * the job running
-			 */
-			if ((t->pid > 0) && (getsid(t->pid) == s->sid)) {
-				retval = true;
-				break;
-			}
-		}	
+		/*
+		 *  Check for existence of any processes in the 
+		 *    job step's session:
+		 */
+		if (kill(-s->sid, 0) == 0)
+			retval = true;
 	} 
 	_shm_unlock();
 
-- 
GitLab