named pipes might be one way, although it is blocking:
setup:
mkfifo /path/to/named/pipe
cgi script:
echo "some data" > /path/to/named/pipe # blocks until other script consumes!
background script:
while :; do
read data < /path/to/named/pipe # blocks until cgi script produces!
do_stuff_with "$data"
done