-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Chet Ramey wrote:
> I think you're slightly misunderstanding how job control and process
> groups interact.
Okay.
> When you run test1 from an interactive shell with job control enabled,
> it is placed into a separate process group. The terminal's foreground
> process group is set to test1's process group, which means that group
> receives keyboard-generated signals like SIGINT.
>
> The shell started to run test1 is not interactive, so job control is
> disabled. This means that all processes started by test1 and its
> descendants are placed into the same process group. Since this is
> the terminal's foreground process group, these processes receive the
> SIGINT.
I see, thanks. Then I have another question: Why does test2 below fail
to trap SIGINT when started by test1? It works when I run test2 directly.
test1 (for reference):
### START SCRIPT ###
#!/bin/bash
test2 &
while /bin/true; do
echo test1 sleeping
sleep 5
done
### END SCRIPT ###
test2 (updated):
### START SCRIPT ###
#!/bin/bash
function shutdown {
echo "Shutting down test2..."
exit 0
}
trap shutdown SIGINT
while /bin/true; do
echo test2 sleeping
sleep 5 &
SLEEP_PID=$!
wait $SLEEP_PID
unset SLEEP_PID
done
### END SCRIPT ###
Thanks in advance.
Regards
Ingemar
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFDx3Fd6sVa+fPBo9YRAmUoAJ9ARnxH4rirGcfegpg20/QxWozyBgCfa98o
UE1JbSi4kq6jDM9Q8iOZNLY=
=pxe6
-----END PGP SIGNATURE-----
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash