--- a/greyhound.php Tue Aug 05 13:17:57 2008 -0400
+++ b/greyhound.php Fri Aug 15 23:22:30 2008 -0400
@@ -23,6 +23,7 @@
// trap SIGTERM
pcntl_signal(SIGTERM, 'sigterm');
pcntl_signal(SIGINT, 'sigterm');
+ pcntl_signal(SIGUSR1, 'handle_refresh_signal');
}
//
@@ -154,3 +155,23 @@
{
burnout("Exception caught while running webserver:\n$e");
}
+
+function handle_refresh_signal()
+{
+ global $httpd;
+ if ( !is_object($httpd) )
+ // we're not serving yet.
+ return false;
+
+ // we've got an httpd instance; rebuild the playlist
+ rebuild_playlist();
+
+ // if this is the parent, also ask the children to rebuild.
+ if ( !defined('HTTPD_WS_CHILD') )
+ {
+ foreach ( $httpd->child_list as $pid )
+ {
+ posix_kill($pid, SIGUSR1);
+ }
+ }
+}