Package: bash
Version: 3.1-1
Severity: normal

With the following script, "sh trapexitbug" and "bash trapexitbug"
cause the EXIT trap to be executed, which breaks traditional sh
compatibility and, IMHO, is not POSIX-compliant (see the explanations
in the script). Other shells, such as dash, ksh and zsh are not
affected by this problem.

----------------------------------------------------------------------------
#!/bin/sh

# Bug: With bash, a kill -TERM causes pterm to be executed.
#
# http://www.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html says:
#     SIGTERM  T  Termination signal.
# and for T:
#     Abnormal termination of the process.  The process is terminated
#     with all the consequences of _exit() except that the status made
#     available to wait() and waitpid() indicates abnormal termination
#     by the specified signal.
#
# http://www.opengroup.org/onlinepubs/009695399/functions/_exit.html says:
#     The _Exit() [CX] and _exit() functions shall not call functions
#     registered with atexit() nor any registered signal handlers.

# Try the following:
#   sh trapexitbug
#   bash trapexitbug
#   dash trapexitbug
#   ksh trapexitbug
#   zsh trapexitbug

pterm()
{
  trap 0
  echo pterm
}

trap pterm 0
echo "PID = $$"
while true; do true; done

# $Id: trapexitbug 10633 2006-01-06 13:26:17Z lefevre $
----------------------------------------------------------------------------

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14.4-20051215
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)

Versions of packages bash depends on:
ii  base-files                    3.1.9      Debian base system miscellaneous f
ii  debianutils                   2.15.2     Miscellaneous utilities specific t
ii  libc6                         2.3.5-11   GNU C Library: Shared libraries an
ii  libncurses5                   5.5-1      Shared libraries for terminal hand

bash recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to