[hackers] [sbase] flock: Close fd early for correct error propagation || sin

From: <git_AT_suckless.org>
Date: Mon, 21 Dec 2015 15:13:41 +0100 (CET)

commit 0c3440253bb7d7496eef18c1c115cba1f823bfb1
Author: sin <sin_AT_2f30.org>
AuthorDate: Mon Dec 21 14:11:07 2015 +0000
Commit: sin <sin_AT_2f30.org>
CommitDate: Mon Dec 21 14:13:36 2015 +0000

    flock: Close fd early for correct error propagation
    
    Spotted by FRIGN.

diff --git a/flock.c b/flock.c
index 863350e..8d015cc 100644
--- a/flock.c
+++ b/flock.c
_AT_@ -69,13 +69,13 @@ main(int argc, char *argv[])
         }
         waitpid(pid, &status, 0);
 
+ if (close(fd) < 0)
+ eprintf("close:");
+
         if (WIFSIGNALED(status))
                 return 128 + WTERMSIG(status);
         if (WIFEXITED(status))
                 return WEXITSTATUS(status);
 
- if (close(fd) < 0)
- eprintf("close:");
-
         return 0;
 }
Received on Mon Dec 21 2015 - 15:13:41 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 21 2015 - 15:24:15 CET