svashisht / rpms / bash

Forked from rpms/bash 4 years ago
Clone

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

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