Bug 151485 - kill doesn't like 'SIG' prefix in bash scripts invoked through 'sh'
Summary: kill doesn't like 'SIG' prefix in bash scripts invoked through 'sh'
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: bash
Version: 4.0
Hardware: i686
OS: Linux
medium
low
Target Milestone: ---
: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-03-18 14:25 UTC by Mike Herrick
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-03-18 14:53:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Mike Herrick 2005-03-18 14:25:39 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030716

Description of problem:
Man page states:

'sigspec is either a  case-insensitive signal name such as SIGKILL (with or
without the SIG prefix)'

In an interactive bash, this seems to be true - the following command works:

kill -SIGUSR1 1

However, if it is placed in a script:

# cat - > /tmp/foo <<EOF
> #!/bin/bash
> type kill
> kill -SIGUSR1 1
> EOF
# sh /tmp/foo
kill is a shell builtin
/tmp/foo: line 3: kill: SIGUSR1: invalid signal specification
#

Removing the 'SIG' prefix solves the problem.


Version-Release number of selected component (if applicable):
bash-3.0-19.2

How reproducible:
Always

Steps to Reproduce:
1.
# cat - > /tmp/foo <<EOF
> #!/bin/bash
> type kill
> kill -SIGUSR1 1
> EOF
# sh /tmp/foo

2.
3.
  

Actual Results:  kill is a shell builtin
/tmp/foo: line 3: kill: SIGUSR1: invalid signal specification


Expected Results:  kill is a shell builtin

Additional info:

Seems to be related to invoking 'sh'.  Invoking 'bash' works:

# sh /tmp/foo
kill is a shell builtin
/tmp/foo: line 3: kill: SIGUSR1: invalid signal specification
# bash /tmp/foo
kill is a shell builtin
# ls -l /bin/sh
lrwxrwxrwx  1 root root 4 Mar  3 16:34 /bin/sh -> bash


I thought the '#!/bin/bash' would explicitly invoke bash.

Same scripts work fine on Enterprise Linux 3 update 4.

SELinux is installed.  Output from sestatus:
# sestatus
SELinux status:         enabled
SELinuxfs mount:        /selinux
Current mode:           enforcing
Mode from config file:  enforcing
Policy version:         18
Policy from config file:targeted

Policy booleans:
allow_ypbind            active
dhcpd_disable_trans     inactive
httpd_disable_trans     inactive
httpd_enable_cgi        active
httpd_enable_homedirs   active
httpd_ssi_exec          active
httpd_tty_comm          inactive
httpd_unified           active
mysqld_disable_trans    inactive
named_disable_trans     inactive
named_write_master_zonesinactive
nscd_disable_trans      inactive
ntpd_disable_trans      inactive
portmap_disable_trans   inactive
postgresql_disable_transinactive
snmpd_disable_trans     inactive
squid_disable_trans     inactive
syslogd_disable_trans   active
winbind_disable_trans   inactive
ypbind_disable_trans    inactive
#

Comment 1 Tim Waugh 2005-03-18 14:53:38 UTC
The '#!/bin/bash' line is only used when executing the shell script directly,
not when the shell script is passed as a parameter to an explicit shell
invocation as in 'sh ./script'.

The kill built-in command adheres to IEEE Std 1003.1-2001 more strictly when the
shell is invoked as 'sh', and so must follow this:

  Values of signal_name shall be recognized in a case-independent
  fashion, without the SIG prefix.

Allowing the SIG prefix is a bash extension as far as I can tell.


Note You need to log in before you can comment on or make changes to this bug.