Skip to content

Commit 10a08cb

Browse files
committed
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
2 parents c042ad5 + d9a65b6 commit 10a08cb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

setup.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,11 +1423,9 @@ const char *resolve_gitdir_gently(const char *suspect, int *return_error_code)
14231423
/* if any standard file descriptor is missing open it to /dev/null */
14241424
void sanitize_stdfds(void)
14251425
{
1426-
int fd = open("/dev/null", O_RDWR, 0);
1427-
while (fd != -1 && fd < 2)
1428-
fd = dup(fd);
1429-
if (fd == -1)
1430-
die_errno(_("open /dev/null or dup failed"));
1426+
int fd = xopen("/dev/null", O_RDWR);
1427+
while (fd < 2)
1428+
fd = xdup(fd);
14311429
if (fd > 2)
14321430
close(fd);
14331431
}

0 commit comments

Comments
 (0)