bug-bash
[Top][All Lists]
Advanced

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

bash doesn't execute SIGCHLD traps in correct context


From: Alexandru Damian
Subject: bash doesn't execute SIGCHLD traps in correct context
Date: Tue, 4 Feb 2014 15:33:03 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello,

I'm facing an interesting problem - Bash doesn't execute SIGCHLD traps
in the correct context. I'm using bash-4.2.

Take this example:

$ reset_trap() { echo RST; trap - CHLD; }
$ trap reset_trap CHLD

Under dash and ksh, once the trap is set, it will execute once, and then
reset, as expected:

# DASH
$ ls -al
total 16
drwxr-xr-x   2 user user  4096 Feb  4 15:23 .
drwxr-xr-x 142 user user 12288 Feb  4 15:23 ..
RST                                                     # trap executed
$ ls -al
total 16
drwxr-xr-x   2 user user  4096 Feb  4 15:23 .
drwxr-xr-x 142 user user 12288 Feb  4 15:23 ..
$                                                       # only once


Under bash, the trap executes, but does not reset itself. 
If I set a similar trap on SIGUSR1, it works as expected.

After debugging, it appears that the trap does not execute in the right
context. 

$ reset_trap() { echo RST; trap - CHLD; }
$ user_trap() { trap; echo USR; trap - USR1; }
$ trap reset_trap CHLD
$ trap user_trap USR1
$ ls

I get this output from the reset_trap handler:

trap -- 'user_trap' SIGUSR1
trap -- 'H�M�)' SIGCHLD
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
RST

Obviusly, something happened on the way to heaven. 
I am not sure in which context it will get executed though.

Please confirm that this not the expected behaviour of the SIGCHLD trap.

Cheers,
Alex




reply via email to

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