Surely you could use PHP's get_headers()
function?
The first element in the array returned will be the response code. If it contains '403' then Drupal returned an "access denied" page.
I'm not sure where the best place to call it would be. Probably hook_exit()
, depending on your needs:
http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_exit/6