dash does not handle ^C trap the same way that bash does

Bug #608894 reported by Andrew Tannenbaum
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
dash (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: dash

The problems with making /bin/sh symlink to dash instead of bash are known (#141481), but I haven't seen this particular problem reported yet.

dash and bash process the ^C (INT) signal differently. Try running the following script (then type ^C) with both bash and dash:

<<<
tint() { echo int; }
thup() { echo hup; }
tchld() { echo chld; }
tterm() { echo term; }
texit() { echo exit; }

# trap tint INT
trap thup HUP
trap tchld CHLD
trap tterm TERM
trap texit EXIT

echo type ^C...
sleep 100
>>>

bash triggers the EXIT. dash triggers no trap.

If you uncomment the INT trap, bash triggers INT and EXIT, and dash triggers INT, CHLD, and EXIT.

I don't know what POSIX dictates or which is correct, I am guessing that any exit should trigger EXIT (so dash is wrong).

Either way, the shells behave differently, and the difference is causing problems in existing Ubuntu scripts. (I found it in /usr/bin/xeno-test.)

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: dash 0.5.5.1-3ubuntu2
ProcVersionSignature: Ubuntu 2.6.32-23.37-generic 2.6.32.15+drm33.5
Uname: Linux 2.6.32-23-generic i686
Architecture: i386
Date: Thu Jul 22 15:12:27 2010
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: dash

Revision history for this message
Andrew Tannenbaum (atannen) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in dash (Ubuntu):
status: New → Confirmed
Revision history for this message
Ján Sáreník (jajomojo) wrote :

Is there progress on this? Anything I can help with?

Revision history for this message
Ján Sáreník (jajomojo) wrote :

By the way, MKSH behaves the same way as dash does.

Revision history for this message
Jarno Suni (jarnos) wrote :

I do not know any other shell than Bash that would run EXIT trap on signal that has its default action.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.