rendered paste body#!/usr/bin/php<?phpdefine('TIMEOUT', 1000);define('VARKEY', 1337);define('SEMKEY', 1);define('MSGKEY', 2);define('MSG_UP', 1);define('MSG_DOWN',2);define('MSG_MAXSIZE',sizeof('1345678901234567890'));$shm_key = ftok(dirname(__FILE__),'a'); //get our shm_key$sem_id = sem_get(SEMKEY); //get our semaphore ID$shm_id = shm_attach($sem_id, TIMEOUT); //get the id for the SHM block$msg_queue = msg_get_queue( MSGKEY,0600); //get our message queue echo "got it, initializing.\n";sem_acquire($sem_id);shm_put_var($shm_id, VARKEY, 'null');sem_release($sem_id);sleep(10);echo "nice nap. starting loop\n";for ($i = 0; $i < 50 ; $i++){ echo "aquireing semaphore... "; echo sem_acquire($sem_id). "\n"; echo "put is: "; echo shm_put_var($shm_id,VARKEY, $i); echo ", value $i\n"; echo "releasing semaphore... "; echo sem_release($sem_id). "\n"; echo "sending message... "; msg_send($msg_queue,MSG_UP,'Updated'); echo "sleeping for 2 seconds... \n";// sleep(1);}echo "sending die mesg\n";msg_send($msg_queue,MSG_DOWN,'shut it down');echo "detaching from shm and sleeping 10 seconds";echo "removing semaphore... ";echo sem_remove($sem_id)."\n";echo "removing shm... ";echo shm_remove($shm_id);//todo close out the message queue... oops.?>