I've got a PHP script that calls the system shell with a piped command. In this case we're talking about a backup script (but it could be anything, I'm asking specifically about the exit status!):
exec( "mysqldump --user=$u --password=$p --host=$h --port=$p $db | gzip -9 > backup.sql.gz", $out, $status );
Now I want to know if the mysqldump command yielded an error, but the
$status variable always seems to contain
0, even if I force an error. It appears to be the exit code of the second command (gzip in this case). I want to be able to see the exit status of the first command in PHP.