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

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