I have two scripts. These are simplified. The root-script.sh
calls userscript.sh
:
root-script.sh:
#!/bin/bash
su - user1 -c "/user1path/user-script.sh"
user-script.sh:
#!/bin/bash
trap 'echo please use x for exit' 2
while x=0; do
read -p "enter x for exit:" answer
if [[ $answer = 'x' ]]; then
echo "exit now"
exit 0
fi
done
If I call user-script.sh it just works as it should:
enter x for exit:
enter x for exit: ^C_please use x for exit
^C_please use x for exit
x
exit now
If I call root-script.sh
as root
and enter a Ctrl-C I get
enter x for exit: ^C
Session terminated, killing shell... ...killed.
Than I get back the root-prompt but the prompt is blocked. With ps I don't see the root-script, only the user-script. If I kill the user-script the root-prompt is usable again.
How can I prevent the root-script-user-script-construction from hanging after SIGINT? Means for me
- Exiting
root-script.sh
anduser-script.sh
or the root-script-user-script-construction should work as same as
user-script.sh
- bash-version: 3.2.51(1)-release (x86_64-suse-linux-gnu)
- os-version: sles11 3.0.93-0.8-default