<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -33,17 +33,33 @@ class Snap_Dispatcher {
      * Under some OSes, additional prefixes may be needed for running
      * PHP properly in the background. If $use_prefix is true, then
      * those prefixes will be prepended to the PHP path.
-     * @param $use_prefix should any OS prefixes be used
+     * @param $use_prefix should any OS prefixes be used, including calls to &quot;nice&quot;
      * @return string
      **/
     protected function getPHP($use_prefix = true) {
-        if (substr(PHP_OS, 0, 3) == 'WIN' &amp;&amp; $use_prefix) {
-            return 'start /b ' . $this-&gt;php;
+        if (!$use_prefix) {
+            return $this-&gt;php;
         }
+        
+        // windows gets a nice via /low
+        if (substr(PHP_OS, 0, 3) == 'WIN') {
+            return 'start /low /b ' . $this-&gt;php;
+        }
+
+        $php = $this-&gt;php;
+        
+        // cgi mode needs &quot;quiet&quot; flag
         if (SNAP_CGI_MODE) {
-            return $this-&gt;php . ' -q';
+            $php .= ' -q';
         }
-        return $this-&gt;php;
+        
+        // get snap NICE option if set and use it
+        $options = Snap_Request::getLongOptions(array('nice' =&gt; ''));
+        if ($options['nice']) {
+            $php = $options['nice'] . ' -n 15 ' . $php;
+        }
+
+        return $php;
     }
     
     /**</diff>
      <filename>core/snap/dispatcher.php</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,7 @@ $options = Snap_Request::getLongOptions(array(
     'mode'      =&gt; 'init',
     'out'       =&gt; 'text',
     'php'       =&gt; 'php',
+    'nice'      =&gt; '',
     'match'     =&gt; '^.*\.stest\.php$',
     'help'      =&gt; false,
     'test'      =&gt; '',</diff>
      <filename>snaptest.php</filename>
    </modified>
    <modified>
      <diff>@@ -27,13 +27,34 @@ if [[ ! -x &quot;$PHPX&quot; ]] ; then
     fi
 fi
 
-if [[ ! -z PHPX ]] ; then
+if [[ ! -z $PHPX ]] ; then
     PHP=$PHPX
 fi
 
+# Auto Locate Nice
+NICEX=`which nice`
+if [[ ! -x &quot;$NICEX&quot; ]] ; then
+    NICEX=&quot;&quot;
+    if [ -z $NICEX ] ; then
+        if [ -x &quot;/usr/local/bin/nice&quot; ] ; then
+            NICEX=&quot;/usr/local/bin/nice&quot;
+        fi
+        if [ -x &quot;/usr/bin/nice&quot; ] ; then
+            NICEX=&quot;/usr/bin/nice&quot;
+        fi
+        if [ -x &quot;/opt/local/bin/nice&quot; ] ; then
+            NICEX=&quot;/opt/local/bin/nice&quot;
+        fi
+    fi
+fi
+
+if [[ ! -z $NICEX ]] ; then
+    NICE=$NICEX
+fi
+
 # parse the options
 CMD=&quot;&quot;
-while getoptex &quot;out. php. match. help;&quot; &quot;$@&quot;
+while getoptex &quot;out. php. nice. match. help;&quot; &quot;$@&quot;
 do
     if [ &quot;$OPTOPT&quot; = &quot;php&quot; ] ; then
         if [ -x &quot;$OPTARG&quot; ] ; then
@@ -43,6 +64,14 @@ do
             exit 0
         fi
     fi
+    if [ &quot;$OPTOPT&quot; = &quot;nice&quot; ] ; then
+        if [ -x &quot;$OPTARG&quot; ] ; then
+            NICE=$OPTARG
+        else
+            echo &quot;The path of $OPTARG was not a valid nice path.&quot;
+            exit 0
+        fi
+    fi
     if [ &quot;$OPTOPT&quot; = &quot;help&quot; ] ; then
         CMD=&quot;$CMD --help&quot;
     else
@@ -77,13 +106,15 @@ CGI=`$PHP -v | grep cgi | wc -l | sed &quot;s/[^0-9]//g&quot;`
 
 # run php on the snaptest.php file with the commands
 if [ &quot;$CGI&quot; = &quot;0&quot; ] ; then
-    CMD=&quot;$PHP -q $FPATH/snaptest.php --php=$PHP $CMD $PTH&quot;
+    CMD=&quot;$PHP -q $FPATH/snaptest.php --php=$PHP --nice=$NICE $CMD $PTH&quot;
 else
     # if we are running in CGI mode, we need to mangle our . characters
     # otherwise PHP mangles them in the request
     PHPSAFE=`echo &quot;$PHP&quot; | sed &quot;s/\./__D_O_T__/g&quot;`
     CMDSAFE=`echo &quot;$CMD&quot; | sed &quot;s/\./__D_O_T__/g&quot;`
     PTHSAFE=`echo &quot;$PTH&quot; | sed &quot;s/\./__D_O_T__/g&quot;`
-    CMD=&quot;$PHP -q $FPATH/snaptest.php --php=$PHPSAFE $CMDSAFE $PTHSAFE&quot;
+    NICESAFE=`echo &quot;$NICE&quot; | sed &quot;s/\./__D_O_T__/g&quot;`
+
+    CMD=&quot;$PHP -q $FPATH/snaptest.php --php=$PHPSAFE --nice=$NICESAFE $CMDSAFE $PTHSAFE&quot;
 fi
 $CMD</diff>
      <filename>snaptest.sh</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ba01e1c3416368e5c5453ec47e015a56c9c4f4ea</id>
    </parent>
  </parents>
  <author>
    <name>Jakob Heuser</name>
    <email>jakob@felocity.org</email>
  </author>
  <url>http://github.com/Jakobo/snaptest/commit/fd09552bca256dd2f608f11a5d146c470392009a</url>
  <id>fd09552bca256dd2f608f11a5d146c470392009a</id>
  <committed-date>2008-04-09T15:33:36-07:00</committed-date>
  <authored-date>2008-04-09T15:33:36-07:00</authored-date>
  <message>Added support for gnu nice when available.</message>
  <tree>d0c366cb30b53dab3c2e5b8969701ee35f75acc1</tree>
  <committer>
    <name>Jakob Heuser</name>
    <email>jakob@felocity.org</email>
  </committer>
</commit>
