--- a/greyhound.php Wed Mar 26 09:57:42 2008 -0400
+++ b/greyhound.php Wed Mar 26 10:24:20 2008 -0400
@@ -12,12 +12,18 @@
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
*/
-// required for signal handling to work
-declare(ticks=1);
-
-// trap SIGTERM
-pcntl_signal(SIGTERM, 'sigterm');
-pcntl_signal(SIGINT, 'sigterm');
+// Try to trap termination signals to cleanly close the socket when needed
+// AmaroK sends a SIGTERM when it is shut down or the user requests to stop
+// the script
+if ( function_exists('pcntl_signal') )
+{
+ // required for signal handling to work
+ declare(ticks=1);
+
+ // trap SIGTERM
+ pcntl_signal(SIGTERM, 'sigterm');
+ pcntl_signal(SIGINT, 'sigterm');
+}
$public = true;
$allowcontrol = true;