Blame SOURCES/fix-shopt-lastpipe-mode-crash.patch

d48a87
From 0eb5e47f531b49c8d048c9ae9657eeb63f49a9f3 Mon Sep 17 00:00:00 2001
d48a87
From: Siteshwar Vashisht <svashisht@redhat.com>
d48a87
Date: Fri, 13 May 2016 01:34:06 +0530
d48a87
Subject: [PATCH] Fix shopt lastpipe mode crash
d48a87
d48a87
---
d48a87
 execute_cmd.c | 23 ++++++++++++++++++++---
d48a87
 1 file changed, 20 insertions(+), 3 deletions(-)
d48a87
d48a87
diff --git a/execute_cmd.c b/execute_cmd.c
d48a87
index c5cf6d2..7b22460 100644
d48a87
--- a/execute_cmd.c
d48a87
+++ b/execute_cmd.c
d48a87
@@ -2254,11 +2254,28 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
d48a87
   if (lastpipe_flag)
d48a87
     {
d48a87
 #if defined (JOB_CONTROL)
d48a87
-      append_process (savestring (the_printed_command), dollar_dollar_pid, exec_result, lastpipe_jid);
d48a87
-#endif
d48a87
+      if (INVALID_JOB (lastpipe_jid) == 0)
d48a87
+        {
d48a87
+          append_process (savestring (the_printed_command_except_trap), dollar_dollar_pid, exec_result, lastpipe_jid);
d48a87
+          lstdin = wait_for (lastpid);
d48a87
+        }
d48a87
+      else
d48a87
+        lstdin = wait_for_single_pid (lastpid);		/* checks bgpids list */
d48a87
+#else
d48a87
       lstdin = wait_for (lastpid);
d48a87
+#endif
d48a87
+
d48a87
 #if defined (JOB_CONTROL)
d48a87
-      exec_result = job_exit_status (lastpipe_jid);
d48a87
+      /* If wait_for removes the job from the jobs table, use result of last
d48a87
+	 command as pipeline's exit status as usual.  The jobs list can get
d48a87
+	 frozen and unfrozen at inconvenient times if there are multiple pipelines
d48a87
+	 running simultaneously. */
d48a87
+      if (INVALID_JOB (lastpipe_jid) == 0)
d48a87
+	exec_result = job_exit_status (lastpipe_jid);
d48a87
+      else if (pipefail_opt)
d48a87
+	exec_result = exec_result | lstdin;	/* XXX */
d48a87
+      /* otherwise we use exec_result */
d48a87
+        
d48a87
 #endif
d48a87
       unfreeze_jobs_list ();
d48a87
     }
d48a87
-- 
d48a87
2.5.5
d48a87