Our testing has revealed that ash's notion of a child pid is incorrect if
'trap' has been used to set a handler. Bisection shows that the regression
was introduced by 238bf187ba5708bc04065b761ffc98c877043fe4.

This patch forcedly clears may_have_traps when traps are cleared and also
adds a testcase for this regression.

Signed-off-by: Alexander Shishkin <[email protected]>
---
 shell/ash.c                              |    2 ++
 shell/ash_test/ash-signals/signal7.right |    1 +
 shell/ash_test/ash-signals/signal7.tests |   12 ++++++++++++
 3 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 shell/ash_test/ash-signals/signal7.right
 create mode 100755 shell/ash_test/ash-signals/signal7.tests

diff --git a/shell/ash.c b/shell/ash.c
index fd119fa..f84c395 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4633,6 +4633,8 @@ clear_traps(void)
                        INT_ON;
                }
        }
+
+       may_have_traps = 0;
 }
 
 /* Lives far away from here, needed for forkchild */
diff --git a/shell/ash_test/ash-signals/signal7.right 
b/shell/ash_test/ash-signals/signal7.right
new file mode 100644
index 0000000..7ef22e9
--- /dev/null
+++ b/shell/ash_test/ash-signals/signal7.right
@@ -0,0 +1 @@
+PASS
diff --git a/shell/ash_test/ash-signals/signal7.tests 
b/shell/ash_test/ash-signals/signal7.tests
new file mode 100755
index 0000000..2142e75
--- /dev/null
+++ b/shell/ash_test/ash-signals/signal7.tests
@@ -0,0 +1,12 @@
+bug() {
+       trap : exit
+       echo parent is $$
+       /bin/sh -c 'echo in child $$' &
+       echo parent thinks child is $!
+}
+
+bug | awk '
+END { print (p_pid != pid) ? "FAIL" : "PASS" }
+/parent thinks child is/ { p_pid = $NF }
+/in child/ { pid = $NF }
+'
-- 
1.7.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to