From 2bc2c9431ab6c4c84db6cc4ecff6b65760aa4123 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 26 Oct 2006 23:43:26 +0000
Subject: [PATCH] svn merge -r9941:9943
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.1 ported as necessary to
 v1.2.

---
 NEWS                | 1 +
 src/sbatch/sbatch.c | 1 +
 src/srun/allocate.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/NEWS b/NEWS
index d30c9c6c82c..f53fb4809b5 100644
--- a/NEWS
+++ b/NEWS
@@ -97,6 +97,7 @@ documents those changes that are of interest to users and admins.
    time
  - Make connect() non-blocking and poll() with timeout to avoid huge 
    waits under some conditions.
+ - Set "ENVIRONMENT=BATCH" environment variable for "srun --batch" jobs only.
 
 * Changes in SLURM 1.1.17
 =========================
diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c
index 8f2a65b34ca..ae062e7048f 100644
--- a/src/sbatch/sbatch.c
+++ b/src/sbatch/sbatch.c
@@ -162,6 +162,7 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->time_limit = opt.time_limit;
 	desc->shared = opt.shared;
 
+	putenv("ENVIRONMENT=BATCH");
 	desc->environment = environ;
 	desc->env_size = envcount (environ);
 	desc->argv = opt.script_argv;
diff --git a/src/srun/allocate.c b/src/srun/allocate.c
index 1685c896664..faec74b4edd 100644
--- a/src/srun/allocate.c
+++ b/src/srun/allocate.c
@@ -547,6 +547,7 @@ job_desc_msg_create_from_opts (char *script)
 		 */
 		xassert (opt.batch);
 
+		putenv("ENVIRONMENT=BATCH");
 		j->environment = environ;
 		j->env_size = envcount (environ);
 		j->script = script;
-- 
GitLab