<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/3574/">https://reviewboard.asterisk.org/r/3574/</a>
     </td>
    </tr>
   </table>
   <br />




<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers and Tzafrir Cohen.</div>
<div>By wdoekes.</div>


<p style="color: grey;"><i>Updated June 3, 2014, 10:49 a.m.</i></p>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">10:17 <@tzafrir_laptop> One minor nit (for a later commit) - the configure syntax of 'test x$foo != x'

So:

- removed the ugly configure syntax in favor of (mostly) test -n and test -z and test "$x" = "y".
- removed excess $ from $((variable+1)) calculation
- added extra double quotes to tackle the unlikely case that someone is using spaces in directories.</pre>
  </td>
 </tr>
</table>





<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-23492">ASTERISK-23492</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">A couple of fixes to safe_asterisk.

In order of appearance:

* Drop the vim #modeline. It isn't used consistently (textwidth was exceeded)
  and anyone who setting tabspace to something other than 8 should be frowned upon.
  (If you want 4 spaces, use expandtab (et) and friends (sts, sw).

* The message() function outputted messages to the terminal where the process
  was initially started: that means that if you start it on terminal A, you kill it
  on B, you get a message about killing it on A again.
  Rewritten to output it to /dev/$TTY if that was set and suppressed otherwise.

* For compatibility with debian users who have been living with this:
  https://github.com/leifmadsen/asterisk/blob/master/debian/patches/safe_asterisk-config
  we allow TTY to be empty or 'no'.

* Consistent spacing: no space before ; and no space after the redirection operators.
  No blobs. Only tabs for indentation.

* If TTY is no (or empty), then redirect all output to /dev/null. This was a daemon
  process, remember?

* Add option to export ASTSAFE_FOREGROUND=1 from the init script that call this. This
  is for compatibility with this:
  https://github.com/leifmadsen/asterisk/blob/master/debian/patches/safe_asterisk-nobg
  Of course that will require a change to this:
  https://github.com/leifmadsen/asterisk/blob/master/debian/asterisk.init
  but that's beyond the scope of asterisk.
  (This is what ticket ASTERISK-23492 is about.)</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I tested TTY=, TTY=no, TTY=9 and tested whether doing this on the asterisk.init script worked:

--- init.orig   2014-05-29 16:54:05.755379751 +0200
+++ /etc/init.d/asterisk        2014-05-29 16:42:20.622731338 +0200
@@ -151,11 +151,11 @@ case "$1" in
                        echo "$DESC is already running. Use restart."
                        exit 0
                fi
-               export SAFE_AST_BACKGROUND=1
                start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
                        $CHDIR_PARM \
                        --exec $REALDAEMON -- $PARAMS > /dev/null
        else
+               export ASTSAFE_FOREGROUND=1
                start-stop-daemon --start --group $GROUP \
                        --background --make-pidfile \
                        $CHDIR_PARM --pidfile "$ASTSAFE_PIDFILE" \


All changes should be backwards compatible, except for the people who expect crap on the
terminal they used to start safe_asterisk on.

I wanted to change the daemonization to make it fully detached (double fork), but that
would probably mess with someones (upstart?) fork-count expectations. So I left that
alone.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> (updated)</h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/branches/1.8/contrib/scripts/safe_asterisk <span style="color: grey">(415051)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/3574/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>




  </div>
 </body>
</html>