close log fd after dup2 to 2

This commit is contained in:
Charles Forsyth 2015-03-17 19:42:33 +00:00
parent 5f914398ca
commit f7faf7651c
1 changed files with 5 additions and 2 deletions

7
u9fs.c
View File

@ -1785,8 +1785,11 @@ main(int argc, char **argv)
if(fd < 0)
sysfatal("cannot open log '%s'", logfile);
if(dup2(fd, 2) < 0)
sysfatal("cannot dup fd onto stderr");
if(fd != 2){
if(dup2(fd, 2) < 0)
sysfatal("cannot dup fd onto stderr");
close(fd);
}
fprint(2, "u9fs\nkill %d\n", (int)getpid());
fmtinstall('F', fcallconv);