diff --git a/Makefile b/Makefile index b2535a67cccb91df0d8b1be3464047de4316a4a3..8799c0745d7e650b52eb0177643321895d917f7d 100644 --- a/Makefile +++ b/Makefile @@ -427,7 +427,7 @@ bininstall: _all $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/ $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/ if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \ - cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\ + cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\ chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\ fi $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR) diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk index 48fd14cd7f85ba1652153acfb3e551de14bcbc16..0464373a71ff882834043b36ec09d6e252b7af0a 100644 --- a/contrib/scripts/safe_asterisk +++ b/contrib/scripts/safe_asterisk @@ -10,6 +10,7 @@ MACHINE=`hostname` # To specify which machine has crashed when getting the mai DUMPDROP=/tmp SLEEPSECS=4 ASTSBINDIR=__ASTERISK_SBIN_DIR__ +ASTPIDFILE=__ASTERISK_VARRUN_DIR__/asterisk.pid # comment this line out to have this script _not_ kill all mpg123 processes when # asterisk exits @@ -95,6 +96,11 @@ if [ ! -w ${DUMPDROP} ]; then exit 1 fi +# +# Don't die if stdout/stderr can't be written to +# +trap '' SIGPIPE + # # Run scripts to set any environment variables or do any other system-specific setup needed # @@ -114,10 +120,10 @@ run_asterisk() if [ "$TTY" != "" ]; then cd /tmp stty sane < /dev/${TTY} - nice -n $PRIORITY ${ASTSBINDIR}/asterisk ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY} + nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY} else cd /tmp - nice -n $PRIORITY ${ASTSBINDIR}/asterisk ${CLIARGS} ${ASTARGS} + nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} fi EXITSTATUS=$? echo "Asterisk ended with exit status $EXITSTATUS" @@ -135,7 +141,11 @@ run_asterisk() if [ "$EXEC" != "" ]; then $EXEC fi - if [ -f /tmp/core ]; then + + PID=`cat ${ASTPIDFILE}` + if [ -f /tmp/core.${PID} ]; then + mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-`date -Iseconds` & + elif [ -f /tmp/core ]; then mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & fi else @@ -144,7 +154,11 @@ run_asterisk() exit 0 else echo "Asterisk died with code $EXITSTATUS." - if [ -f /tmp/core ]; then + + PID=`cat ${ASTPIDFILE}` + if [ -f /tmp/core.${PID} ]; then + mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-`date -Iseconds` & + elif [ -f /tmp/core ]; then mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & fi fi