bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a kill -TERM causes the EXIT trap to be executed


From: Vincent Lefevre
Subject: a kill -TERM causes the EXIT trap to be executed
Date: Mon, 09 Jan 2006 05:02:03 +0100

Configuration Information [Automatically generated, do not change]:
Machine: powerpc
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='powerpc' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='powerpc-unknown-linux-gnu' 
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g 
-O2
uname output: Linux ay.vinc17.org 2.6.12-20050829 #1 Mon Aug 29 18:18:59 CEST 
2005 ppc GNU/Linux
Machine Type: powerpc-unknown-linux-gnu

Bash Version: 3.1
Patch Level: 0
Release Status: release

Description:
  An EXIT trap is executed when the process is killed, e.g. by the
  SIGTERM signal, which breaks traditional sh compatibility and, IMHO,
  is not POSIX-compliant (see the explanations in the script below).
  Other shells, such as dash, ksh and zsh are not affected by this
  problem.
  I've also reported this bug on the Debian BTS (bug 346215).

Repeat-By:
  With the following script, "sh trapexitbug" (under Linux) and
  "bash trapexitbug" cause the EXIT trap to be executed.

#!/bin/sh

# Bug: With bash, a kill -TERM causes the EXIT trap to be executed.
# See <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=346215>,
# reported against bash/3.1-1 on 2006-01-06.
#
# 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 10667 2006-01-09 03:55:58Z lefevre $




reply via email to

[Prev in Thread] Current Thread [Next in Thread]