OVERVIEW: When using traps in Ash scripts, currently running commands return immediately when the trap signal is sent. On an Ubuntu system running Bash, the trap is executed when the currently running command has completed. This is the expected execution according to section 12.2.2 of the Bash Guide for Beginners (http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html). STEPS TO REPRODUCE: The following code is an example: #!/bin/sh trap 'echo jake' SIGUSR1 while true do echo "before sleep" sleep 5 echo "after sleep" done ACTUAL RESULTS: trap immediately interrupts the currently running process (echo "jake"). EXPECTED RESULTS: trap is pending until the 5 second sleep is done. PLATFORM: Using BusyBox 1.11.2 on a PowerPC Linux (OpenWRT 8.01) system.
Which bbox version is it? How do you send USR1 to it? I am trying to reproduce it with current git: #!/bin/sh trap 'echo jake' SIGUSR1 echo pid:$$ while true; do echo "before sleep `date +'%H:%M:%S'`" sleep 5 echo "after sleep `date +'%H:%M:%S'`" done # ./busybox ash z pid:11975 before sleep 05:06:04 after sleep 05:06:09 before sleep 05:06:09 after sleep 05:06:14 before sleep 05:06:14 after sleep 05:06:19 before sleep 05:06:19 after sleep 05:06:24 before sleep 05:06:24 after sleep 05:06:29 before sleep 05:06:29 jake after sleep 05:06:34 before sleep 05:06:34 jake after sleep 05:06:39 before sleep 05:06:39 jake after sleep 05:06:44 before sleep 05:06:44 jake after sleep 05:06:49 before sleep 05:06:49 after sleep 05:06:54 before sleep 05:06:54 (I was running "kill -USR1 11975" in another terminal) As you see, it works correctly.