diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-09-20 15:20:45 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-09-20 15:20:45 -0700 |
| commit | 10a08cbd397644f205a1212409896928988c2c83 (patch) | |
| tree | 2978d1329cdcf2ba0074ded6a627c440a96eada1 | |
| parent | c042ad5ad58d4e43aadc806850e76fef73848d2c (diff) | |
| parent | d9a65b6c0a9171a3ff636e59a3e435eda8f50e5b (diff) | |
| download | git-10a08cbd397644f205a1212409896928988c2c83.tar.xz | |
Merge branch 'rs/setup-use-xopen-and-xdup'
Code clean-up.
* rs/setup-use-xopen-and-xdup:
setup: use xopen and xdup in sanitize_stdfds
| -rw-r--r-- | setup.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -1423,11 +1423,9 @@ const char *resolve_gitdir_gently(const char *suspect, int *return_error_code) /* if any standard file descriptor is missing open it to /dev/null */ void sanitize_stdfds(void) { - int fd = open("/dev/null", O_RDWR, 0); - while (fd != -1 && fd < 2) - fd = dup(fd); - if (fd == -1) - die_errno(_("open /dev/null or dup failed")); + int fd = xopen("/dev/null", O_RDWR); + while (fd < 2) + fd = xdup(fd); if (fd > 2) close(fd); } |
