Fix timing to save errno
The timing to save some errnos is after DEBUG output, not immediately after the system call.
Fix to save errno before DEBUG output so that errno is not overwritten by DEBUG output processing.
Reviewed-by: Pavel Březina <pbrezina@redhat.com>