Fixed execute_safe. If an error occurs  will contain code field instead errno