Merge branch 'tr/fd-gotcha-fixes'
Two places we did not check return value (expected to be a file descriptor) correctly. * tr/fd-gotcha-fixes: run-command: dup_devnull(): guard against syscalls failing git_mkstemps: correctly test return value of open()
This commit is contained in:
commit
1d1934caf1
@ -76,7 +76,10 @@ static inline void close_pair(int fd[2])
|
||||
static inline void dup_devnull(int to)
|
||||
{
|
||||
int fd = open("/dev/null", O_RDWR);
|
||||
dup2(fd, to);
|
||||
if (fd < 0)
|
||||
die_errno(_("open /dev/null failed"));
|
||||
if (dup2(fd, to) < 0)
|
||||
die_errno(_("dup2(%d,%d) failed"), fd, to);
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user