|Summary:||ASTERISK-17251: asterisk sometimes returns 0 on segfault, safe_asterisk doesn't restart|
|Date Opened:||2011-01-14 20:00:27.000-0600||Date Closed:|
|Description:||While trying to diagnose a segfault, and using safe_asterisk to automatically restart, sometimes asterisk was not restarted as expected. The reason is clear, asterisk was returning 0.|
****** ADDITIONAL INFORMATION ******
As a test I forced a segfault when calling system(), by adding in app_system.c
char *s = -1L;
*s = 'H';
and safe_asterisk was used to start (and monitor the result).
$ asterisk -r
(dial the test to call system())
Disconnected from Asterisk server
Executing last minute cleanups
The syslog contains...
user.info kernel: asterisk: segfault at ffffffff ip 4069e970 sp bb7fb890 error 6 in app_system.so[4069e000+2000]
But safe_asterisk notes "Asterisk shutdown normally." indicating a return code of 0.
It appears that in main/asterisk.c the ast_el_read_char() function is added with
el_set(el, EL_GETCFN, ast_el_read_char);
and quit_handler() is called, resulting in an exit(0);
Sorry, I'm not offering a fix, but maybe this description may inspire a fix.
A workaround is in safe_asterisk with $EXITSTATUS -eq 0 test the last entry in the syslog with
grep -q 'asterisk.*: segfault at '
and set EXITSTATUS to something greater than 128