From 6fb2e317bf6db2ccfaed3a6d97ae313716db00f1 Mon Sep 17 00:00:00 2001
From: Mark Grondona <mgrondona@llnl.gov>
Date: Fri, 30 Aug 2002 00:08:02 +0000
Subject: [PATCH]  o small, temporary fixes for io truncation

---
 src/srun/srun.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/srun/srun.c b/src/srun/srun.c
index 980b0dee7bb..28ab434b21c 100644
--- a/src/srun/srun.c
+++ b/src/srun/srun.c
@@ -75,6 +75,7 @@ main(int ac, char **av)
 	allocation_resp *resp;
 	job_t *job;
 	struct sigaction action;
+	int i;
 
 	log_options_t logopt = LOG_OPTS_STDERR_ONLY;
 
@@ -189,10 +190,14 @@ main(int ac, char **av)
 	/* kill signal thread */
 	pthread_kill(job->sigid, SIGTERM);
 
-	/* flush stdio and kill io thread */
-	fflush(stderr);
-	fflush(stdout);
-	pthread_kill(job->ioid, SIGTERM);
+	/* wait for  stdio */
+	for (i = 0; i < opt.nprocs; i++) {
+		if (job->out[i] == -1)
+			job->out[i] = -9;
+		if (job->err[i] == -1)
+			job->err[i] = -9;
+	}
+	pthread_join(job->ioid, NULL);
 
 	exit(0);
 }
-- 
GitLab