From 9a6ebac196c356a16baee243bb0a80ebe3a6f09c Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 1 Mar 2007 20:57:47 +0000
Subject: [PATCH] svn merge -r11041:11048
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.1

---
 NEWS                       |  5 +++++
 src/slurmd/slurmstepd/io.c | 14 ++++++++++++--
 src/srun/srun_job.c        | 14 ++++++++++++--
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 874469aaf7a..6eb7606bedb 100644
--- a/NEWS
+++ b/NEWS
@@ -235,6 +235,11 @@ documents those changes that are of interest to users and admins.
     the code)
  -- Added support for OSX build.
 
+* Changes in SLURM 1.1.32
+=========================
+ - If a job's stdout/err file names are unusable (bad path), use the 
+   default names.
+ 
 * Changes in SLURM 1.1.31
 =========================
  - Correctly identify a user's login shell when running "srun -b --uid"
diff --git a/src/slurmd/slurmstepd/io.c b/src/slurmd/slurmstepd/io.c
index f1949ea9109..143b6f3eb91 100644
--- a/src/slurmd/slurmstepd/io.c
+++ b/src/slurmd/slurmstepd/io.c
@@ -696,7 +696,12 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 				    O_CREAT|O_WRONLY|O_TRUNC|O_APPEND, 0666);
 		if (task->stdout_fd == -1) {
 			error("Could not open stdout file: %m");
-			return SLURM_ERROR;
+			xfree(task->ofname);
+			task->ofname = fname_create(job, "slurm-%J.out", 0);
+			task->stdout_fd = open(task->ofname, 
+				O_CREAT|O_WRONLY|O_TRUNC|O_APPEND, 0666);
+			if (task->stdout_fd == -1)
+				return SLURM_ERROR;
 		}
 		fd_set_close_on_exec(task->stdout_fd);
 		task->from_stdout = -1; /* not used */
@@ -729,7 +734,12 @@ _init_task_stdio_fds(slurmd_task_info_t *task, slurmd_job_t *job)
 				    O_CREAT|O_WRONLY|O_TRUNC|O_APPEND, 0666);
 		if (task->stderr_fd == -1) {
 			error("Could not open stderr file: %m");
-			return SLURM_ERROR;
+			xfree(task->efname);
+			task->efname = fname_create(job, "slurm-%J.err", 0);
+			task->stderr_fd = open(task->efname,
+				O_CREAT|O_WRONLY|O_TRUNC|O_APPEND, 0666);
+			if (task->stderr_fd == -1)
+				return SLURM_ERROR;
 		}
 		fd_set_close_on_exec(task->stderr_fd);
 		task->from_stderr = -1; /* not used */
diff --git a/src/srun/srun_job.c b/src/srun/srun_job.c
index 197692915ea..c5c6c548149 100644
--- a/src/srun/srun_job.c
+++ b/src/srun/srun_job.c
@@ -238,7 +238,12 @@ job_step_create_allocation(uint32_t job_id)
 		 * the vars then.
 		 */
 		if (!opt.nodes_set) {
-			if(opt.nprocs_set)
+			/* we don't want to set the number of nodes =
+			 * to the number of requested processes unless we
+			 * know it is less than the number of nodes
+			 * in the allocation
+			 */
+			if(opt.nprocs_set && (opt.nprocs < ai->nnodes))
 				opt.min_nodes = opt.nprocs;
 			else
 				opt.min_nodes = ai->nnodes;
@@ -293,7 +298,12 @@ job_step_create_allocation(uint32_t job_id)
 		hostlist_destroy(hl);			
 	} else {
 		if (!opt.nodes_set) {
-			if(opt.nprocs_set)
+			/* we don't want to set the number of nodes =
+			 * to the number of requested processes unless we
+			 * know it is less than the number of nodes
+			 * in the allocation
+			 */
+			if(opt.nprocs_set && (opt.nprocs < ai->nnodes))
 				opt.min_nodes = opt.nprocs;
 			else
 				opt.min_nodes = ai->nnodes;
-- 
GitLab