[Home]

Summary:ASTERISK-08859: [patch] A few problems in safe_asterisk
Reporter:Tony Mountifield (softins)Labels:
Date Opened:2007-02-22 07:40:24.000-0600Date Closed:2007-05-11 11:36:39
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) safe_asterisk_trunk.diff
( 1) safe_asterisk.diff
Description:The safe_asterisk script suffers from a few problems, which have been fixed in the attached patch. The patch is for 1.2, but the problems appear still to exist in trunk.

The problems with the existing version are:
a) Asterisk forks and returns immediately to safe_asterisk if CONSOLE=no (which omits the -c option). This prevents safe_asterisk from later responding to a crash by storing the core file, notifying and restarting asterisk. Fixed by specifying -f (never fork) in the invocation of asterisk.

b) When safe_asterisk is invoked from init.d/asterisk, it is left with unwritable stdout and stderr. This results in the script dying with SIGPIPE when it tries to echo, and therefore failing to restart asterisk. For continued operation, SIGPIPE should be ignored. Fixed using "trap".

c) Core files may be named "core.$PID" instead of just "core", preventing the current script from moving the core file correctly. Fixed by fetching the PID from the leftover asterisk.pid file and testing both forms of corefile name. This also required the change to Makefile to substitute the /var/run directory name.

Please see the attached diff file, which contains patches to both contrib/scripts/safe_asterisk and Makefile
Comments:By: Michiel van Baak (mvanbaak) 2007-02-25 15:23:57.000-0600

Updated your patch to apply to svn trunk :)

By: Clod Patry (junky) 2007-04-04 00:44:17

I agree the -f for where the TTY is "".
but why are ya using non-fork for "$TTY" != "" ?

By: Tony Mountifield (softins) 2007-04-04 01:43:20

Because we never want Asterisk to fork when called from safe_asterisk. We always want it _not_ to return until it has crashed or been stopped.

When -c is specified, -f is not required, but leaving it there doesn't hurt either.

By: Clod Patry (junky) 2007-04-09 18:39:41

+1 for me.

By: Michiel van Baak (mvanbaak) 2007-05-05 08:49:19

ping

By: Tilghman Lesher (tilghman) 2007-05-11 11:36:38

Fixed in 63903; merged to 1.4 in 63905, merged to trunk in 63906.