Use _exit() instead of return if exec* fails

This commit is contained in:
sin 2014-11-13 17:06:18 +00:00
parent 2869adf458
commit 44b3ea8f76

View File

@ -33,7 +33,7 @@ main(int argc, char *argv[])
if(isatty(STDOUT_FILENO)) { if(isatty(STDOUT_FILENO)) {
if((fd = open("nohup.out", O_APPEND|O_CREAT, if((fd = open("nohup.out", O_APPEND|O_CREAT,
S_IRUSR|S_IWUSR)) == -1) { S_IRUSR|S_IWUSR)) == -1) {
enprintf(Error, "open nohup.out:"); enprintf(Error, "open nohup.out:");
} }
if(dup2(fd, STDOUT_FILENO) == -1) if(dup2(fd, STDOUT_FILENO) == -1)
@ -46,6 +46,5 @@ main(int argc, char *argv[])
execvp(argv[0], &argv[0]); execvp(argv[0], &argv[0]);
enprintf(errno == ENOENT ? Error : Found, "exec %s:", argv[0]); enprintf(errno == ENOENT ? Error : Found, "exec %s:", argv[0]);
_exit(Error);
return Error;
} }