A one-line compilation of safe mode, function exists, and disabled exec using some of the techniques found on various SO posts.
This will check that exec is available and enabled BEFORE trying to run it. If you run exec() and the function does not exist or is disabled a warning will be generated. Depending on the server settings that may render to the browser and will almost-always write a line to a log file = performance hit.
// Exec function exists.
// Exec is not disabled.
// Safe Mode is not on.
$exec_enabled =
function_exists('exec') &&
!in_array('exec', array_map('trim',explode(', ', ini_get('disable_functions')))) &&
!(strtolower( ini_get( 'safe_mode' ) ) != 'off')
;
if ($exec_enabled) { exec('blah'); }