[BusyBox 0001984]: No trap handlers are called when wait is interrupted (with possible fix)

bugs at busybox.net bugs at busybox.net
Sun Feb 10 19:04:06 UTC 2008


The following issue has been CLOSED 
====================================================================== 
http://busybox.net/bugs/view.php?id=1984 
====================================================================== 
Reported By:                Ronald Wahl
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1984
Category:                   Other
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     closed
Resolution:                 open
Fixed in Version:           
====================================================================== 
Date Submitted:             01-28-2008 13:47 PST
Last Modified:              02-10-2008 11:04 PST
====================================================================== 
Summary:                    No trap handlers are called when wait is interrupted
(with possible fix)
Description: 
The following shell sccrips does not behave correctly:

----------------------------------
trap_handler () {
    echo trap
}

trap trap_handler USR1

sleep 3600 &
while(true); do wait; done
----------------------------------

Expected behavior: Sending a USR1 signal to the shell should cause "trap"
to be printed each time the signal is sent.

Actual behavior:
  bash: works as expected
  1.01: works as expected
  1.1.x ... 1.4.x: only the first signal is honoured
  1.5.x ... 1.9.0: nothing happens

The bug came with SVN revision 18198 of ash.c:
------------------------------
@@ -324,11 +331,13 @@
 onsig(int signo)
 {
 	gotsig[signo - 1] = 1;
-	pendingsigs = signo;
+	pendingsig = signo;
 
 	if (exsig || (signo == SIGINT && !trap[SIGINT])) {
-		if (!suppressint)
+		if (!suppressint) {
+			pendingsig = 0;
 			raise_interrupt();
+		}
 		intpending = 1;
 	}
 }
------------------------------

If I remove the "pendingsig = 0;" before raise_interrupt(); it starts
working again.

I'm not sure if this is the right fix. Can anyone comment on this?
====================================================================== 

---------------------------------------------------------------------- 
 Ronald Wahl - 01-28-08 14:22  
---------------------------------------------------------------------- 
Some additional suggestion: Probably swapping

pendingsig = 0;
raise_interrupt();

is a better approach? 

---------------------------------------------------------------------- 
 vda - 01-28-08 15:50  
---------------------------------------------------------------------- 
"pendingsig = 0" was added because of this issue:

http://busybox.net/bugs/view.php?id=1280 

---------------------------------------------------------------------- 
 vda - 01-28-08 15:55  
---------------------------------------------------------------------- 
Swapping "pendingsig = 0;" with "raise_interrupt();" is wrong:
raise_interrupt() never returns. 

---------------------------------------------------------------------- 
 Ronald Wahl - 01-28-08 16:18  
---------------------------------------------------------------------- 
if (signo == SIGINT && !trap[SIGINT]) pendingsig = 0;

solves my issue and bug 2 in issue 1280.

 

---------------------------------------------------------------------- 
 vda - 02-10-08 11:04  
---------------------------------------------------------------------- 
Fixed in revision 20973. Thanks. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
01-28-08 13:47  Ronald Wahl    New Issue                                    
01-28-08 13:47  Ronald Wahl    Status                   new => assigned     
01-28-08 13:47  Ronald Wahl    Assigned To               => BusyBox         
01-28-08 14:22  Ronald Wahl    Note Added: 0003534                          
01-28-08 15:50  vda            Note Added: 0003539                          
01-28-08 15:55  vda            Note Added: 0003544                          
01-28-08 16:18  Ronald Wahl    Note Added: 0003549                          
01-28-08 16:18  Ronald Wahl    Note Edited: 0003549                         
02-10-08 11:04  vda            Status                   assigned => closed  
02-10-08 11:04  vda            Note Added: 0003824                          
======================================================================




More information about the busybox-cvs mailing list