If I understand well you want to give the ability to the user to interrupt a running process and proceed with the following statements in the script, is it correct?
In this case, if you want to use Ctrl-C to interrupt a single process, you have to use
trap to execute a different action, otherwise the whole script will be interrupted. Then you launch the interruptible command in background and use
wait to pause the script until the process has terminated OR until the user presses Ctrl-C to stop it. Example:
Code:
#!/bin/bash
#
function control_c () {
kill -9 $pid
}
trap control_c SIGINT
command_one
command_two &
pid=$!
echo "Press Ctrl-C to stop the execution of current process..." && wait $pid
command_three &
pid=$!
echo "Press Ctrl-C to stop the execution of current process..." && wait $pid
Hope this helps.