From 4d8a8cc68cfde1ababf1cad58de4285401b450d0 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Tue, 7 Jan 2003 00:32:39 +0000
Subject: [PATCH] Replace SIGTERM to threads with pthread_cancel to avoid
 conflicts with TotalView (it was intercepting the SIGTERM and reporting
 srun's tasks in addition to the user's tasks - very confusing).

---
 src/srun/job.c      | 2 +-
 src/srun/msg.c      | 7 -------
 src/srun/reattach.c | 2 +-
 src/srun/srun.c     | 4 ++--
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/srun/job.c b/src/srun/job.c
index 61ffc9e90e8..9b7b684c6af 100644
--- a/src/srun/job.c
+++ b/src/srun/job.c
@@ -275,7 +275,7 @@ job_force_termination(job_t *job)
 		update_job_state(job, SRUN_JOB_OVERDONE);
 	}
 
-	pthread_kill(job->ioid, SIGTERM);
+	pthread_cancel(job->ioid);
 }
 
 void job_fatal(job_t *job, const char *msg)
diff --git a/src/srun/msg.c b/src/srun/msg.c
index fce46306a7f..4db735f54ef 100644
--- a/src/srun/msg.c
+++ b/src/srun/msg.c
@@ -488,13 +488,6 @@ _msg_thr_poll(job_t *job)
 
 	while (1) {
 		while ((rc = poll(fds, nfds, POLL_TIMEOUT_MSEC)) <= 0) {
-#ifdef HAVE_TOTALVIEW
-			if (MPIR_being_debugged && MPIR_debug_gate &&
-			    (!sent_task_cont)) {
-				sent_task_cont = true;
-				fwd_signal(job, SIGCONT);
-			}
-#endif
 			if (rc == 0) {	/* timeout */
 				if (job->state == SRUN_JOB_FAILED)
 					pthread_exit(0);
diff --git a/src/srun/reattach.c b/src/srun/reattach.c
index 720ab6d1e0a..a522e5e8917 100644
--- a/src/srun/reattach.c
+++ b/src/srun/reattach.c
@@ -493,7 +493,7 @@ int reattach()
 		error ("Attach to job failed!");
 	}
 
-	pthread_kill(job->jtid, SIGTERM);
+	pthread_cancel(job->jtid);
 	pthread_join(job->ioid, NULL);
 
 	/* _complete_job(job); */
diff --git a/src/srun/srun.c b/src/srun/srun.c
index 616fa100eb3..ac64bfaebf4 100644
--- a/src/srun/srun.c
+++ b/src/srun/srun.c
@@ -217,10 +217,10 @@ srun(int ac, char **av)
 	}
 
 	/* kill launch thread */
-	pthread_kill(job->lid, SIGTERM);
+	pthread_cancel(job->lid);
 
 	/* kill msg server thread */
-	pthread_kill(job->jtid, SIGTERM);
+	pthread_cancel(job->jtid);
 
 	/* wait for stdio */
 	if (pthread_join(job->ioid, NULL) < 0) {
-- 
GitLab