Summary:ASTERISK-03741: SIGCHLD from exiting AGI script hangs up other call
Reporter:staffanu (staffanu)Labels:
Date Opened:2005-03-22 14:17:57.000-0600Date Closed:2008-01-15 15:29:39.000-0600
Versions:Frequency of
Environment:Attachments:( 0) patch-asterisk.c
Description:The problem occurs for AGI scripts that use the GET DATA function: If two calls access the AGI script, and the first to call hangs up, the other call is also terminated.  The thread for the second call is interrupted with errno=EINTR on its call to poll(2) in

Mar 22 01:49:00 WARNING[9633]: file.c:1073 ast_waitstream_full: Wait failed (Interrupted system call)

The reason the call to poll(2) is interrupted is that the process receives SIGCHLD when the first AGI script dies.


A simple AGI script for reproducing the problem:

while true; do read a; if [ "$a" = "" ]; then break; fi; done
read response
echo GET DATA pbx-invalid 50000 4
read response

Call the script from two phones, and hang up the first one.  The second call will almost certainly be hang up by Asterisk.

The patch is tested on FreeBSD 5.3-STABLE as of 26 February 2005.  From what I understand, the only reason for having the signal handler for SIGCHLD is to reap zombie processes.  Using the SIG_IGN action for SIGCHLD makes this unnecessary, and also has the benefit of not receiving an EINTR error.

I have not tested the patch on Linux, but from what I can understand, it is allowed to use SIG_IGN for SIGCHLD in Linux now.  Maybe it won't work on older systems?

And yes, I have signed a disclaimer (faxed today).
Comments:By: staffanu (staffanu) 2005-03-22 14:25:52.000-0600

One more thing: Maybe this bug is actually the same as bugs 0002993 and 0003739?

edited on: 03-22-05 14:26

By: Mark Spencer (markster) 2005-03-22 14:39:40.000-0600

We cannot ignore SIGCHLD as we have to be able to reap the dead processes to prevent zombies.  I was trying to see what the problem in file.c might be (it should not cause a hangup that poll was interrupted) but the line number you indicated does not contain the message you posted.  I've patched CVS head to prevent this issue, but you will have to update to latest CVS head.

By: staffanu (staffanu) 2005-03-22 15:17:23.000-0600

I'm sorry about the line number.  I was reproducing the bug on 1.0.6 earlier, and the log message was from that.  On HEAD (from about 20 hours ago) the message is:

Mar 22 22:15:03 WARNING[13572]: file.c:1084 ast_waitstream_full: Wait failed (Interrupted system call)

By: staffanu (staffanu) 2005-03-22 15:23:18.000-0600

I've also seen the same problem logged from line ast_waitfordigit_full in channel.c:1182, but not nearly as often.  When it happened, it also resulted in a hangup.

By: Mark Spencer (markster) 2005-03-22 16:50:41.000-0600

I put in a check for that one too.  Again, please let me know if these changes are makinga  difference.

By: staffanu (staffanu) 2005-03-22 16:50:55.000-0600

After cvs up to get your patch, the problem was gone, mostly.  I could still get a hangup once in a while with the log message from channel.c (see my previous bugnote).  I added the analogue to your file.c patch to channel.c, and the problem seems to be gone completely.  (I've made about 25 calls to test.)


By: Mark Spencer (markster) 2005-03-22 17:47:31.000-0600

Fixed in CVS head.  Thanks.

By: Russell Bryant (russell) 2005-03-31 21:20:29.000-0600

fixed in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:28:17.000-0600

Repository: asterisk
Revision: 5231

U   trunk/file.c

r5231 | markster | 2008-01-15 15:28:16 -0600 (Tue, 15 Jan 2008) | 2 lines

Ignore interrupted system calls (bug ASTERISK-3741)



By: Digium Subversion (svnbot) 2008-01-15 15:28:18.000-0600

Repository: asterisk
Revision: 5232

U   trunk/channel.c

r5232 | markster | 2008-01-15 15:28:17 -0600 (Tue, 15 Jan 2008) | 2 lines

Make sure that waitfordigit_full doesn't hangup on -EINTR (bug ASTERISK-3741)



By: Digium Subversion (svnbot) 2008-01-15 15:29:39.000-0600

Repository: asterisk
Revision: 5328

U   branches/v1-0/CHANGES
U   branches/v1-0/channel.c
U   branches/v1-0/file.c

r5328 | russell | 2008-01-15 15:29:39 -0600 (Tue, 15 Jan 2008) | 2 lines

ignore interrupted system calls (bug ASTERISK-3741)