[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Background processes receive SIGINT even though they shouldn't
From: |
Ingemar Nilsson |
Subject: |
Background processes receive SIGINT even though they shouldn't |
Date: |
Tue, 10 Jan 2006 11:32:21 +0100 |
User-agent: |
Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
- -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
- -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
- -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE
- -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe
- -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4
- -fasynchronous-unwind-tables
uname output: Linux tyrannosaurus 2.6.14-1.1656_FC4 #1 Thu Jan 5
22:13:22 EST 2006 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu
Bash Version: 3.0
Patch Level: 16
Release Status: release
Description:
In some cases, background processes receive SIGINT from the
terminal where it was started even though the manual states
that such processes are immune to keyboard-generated signals.
This is best explained by trying out the example below.
There is a reason for the seemingly complex sleep arrangement
in test2. This is really a condensed version of a much larger
script, but it still demonstrates the problem well.
Repeat-By:
1) Create two shell scripts, test1 and test2, which are
supplied below:
test1:
### START SCRIPT ###
#!/bin/bash
test2 &
while /bin/true; do
echo test1 sleeping
sleep 5
done
### END SCRIPT ###
test2:
### START SCRIPT ###
#!/bin/bash
while /bin/true; do
echo test2 sleeping
sleep 5 &
SLEEP_PID=$!
wait $SLEEP_PID
unset SLEEP_PID
done
### END SCRIPT ###
2) Run test1 from the terminal
3) Interrupt it with CTRL-C
4) Notice that test2 was also interrupted. This can also be
done by finding the PID of test2 and letting strace attach
to the process before interrupting test1. Strace will report
that a SIGINT was caught.
Fix:
N/A
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFDw4016sVa+fPBo9YRAj0qAJ49V67E1gVRq+1sfKlx9ndYacEGkwCgrRoA
LvtXYfV3IZaOdFfiEypResw=
=gAR/
-----END PGP SIGNATURE-----
- Background processes receive SIGINT even though they shouldn't,
Ingemar Nilsson <=