From 8cfe42d94ce9bafee7c9159b7426b1364867ba24 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Fri, 18 Jul 2008 22:53:28 +0000
Subject: [PATCH] svn merge -r14569:14574
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.2

---
 NEWS            |  4 ++--
 src/srun/srun.c | 22 ++++++++++++++++------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index 123d2eaabf4..236144c8195 100644
--- a/NEWS
+++ b/NEWS
@@ -407,13 +407,13 @@ documents those changes that are of interest to users and admins.
 
 * Changes in SLURM 1.2.33
 =========================
- -- Cancelled or Failed jobs will now report there job and step id on exit
+ -- Cancelled or Failed jobs will now report their job and step id on exit
  -- Add SPANK items available to get: SLURM_VERSION, SLURM_VERSION_MAJOR,
     SLURM_VERISON_MINOR and SLURM_VERSION_MICRO.
  -- Fixed handling of SIGPIPE in srun. Abort job.
  -- Fix bug introduced to MVAPICH plugin preventing use of TotalView debugger.
  -- Modify slurmctld to get srun/salloc network address based upon the incoming
-    message rather than hostname set by the user command (more reliable).
+    message rather than hostname set by the user command (backport of logic in 	   SLURM v1.3).
 
 * Changes in SLURM 1.2.32
 =========================
diff --git a/src/srun/srun.c b/src/srun/srun.c
index b47b22ead85..b02333867c9 100644
--- a/src/srun/srun.c
+++ b/src/srun/srun.c
@@ -120,6 +120,7 @@ static int   _become_user (void);
 static int   _call_spank_local_user (srun_job_t *job);
 static void  _define_symbols(void);
 static void  _handle_intr();
+static void  _handle_pipe(int signo);
 static void  _handle_signal(int signo);
 static void  _print_job_information(resource_allocation_response_msg_t *resp);
 static void  _pty_restore(void);
@@ -241,11 +242,6 @@ int srun(int ac, char **av)
 
 		if (!job || create_job_step(job) < 0)
 			exit(1);
-		/* ignore sigpipe for steps.  This is already done
-		 * when allocating nodes elsewhere.
-		 */
-		xsignal(SIGPIPE, ignore_signal);
-
 	} else {
 		got_alloc = 1;
 		/* Combined job allocation and job step launch */
@@ -1080,6 +1076,16 @@ static void _handle_intr()
 	}
 }
 
+static void _handle_pipe(int signo)
+{
+	static int ending = 0;
+
+	if(ending)
+		return;
+	ending = 1;
+	slurm_step_launch_abort(job->step_ctx);
+}
+
 static void _handle_signal(int signo)
 {
 	debug2("got signal %d", signo);
@@ -1116,7 +1122,7 @@ static int _setup_signals()
 {
 	int sigarray[] = {
 		SIGINT,  SIGQUIT, /*SIGTSTP,*/ SIGCONT, SIGTERM,
-		SIGALRM, SIGUSR1, SIGUSR2, /* SIGPIPE,*/ 0
+		SIGALRM, SIGUSR1, SIGUSR2, /*SIGPIPE,*/ 0
 	};
 	int rc = SLURM_SUCCESS, i=0, signo;
 
@@ -1125,6 +1131,10 @@ static int _setup_signals()
 
 	while ((signo = sigarray[i++])) 
 		xsignal(signo, _handle_signal);
+	/* special case for SIGPIPE since we don't want to print stuff
+	 * and get into a locked up state
+	 */
+	xsignal(SIGPIPE, _handle_pipe);
 
 	return rc;
 }
-- 
GitLab