Ensure we return a proper error value in setsid(1)

This commit is contained in:
sin 2014-01-27 15:15:58 +00:00
parent a0fbe3278a
commit 6a18e77962

View File

@ -15,6 +15,8 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int savederrno;
ARGBEGIN { ARGBEGIN {
default: default:
usage(); usage();
@ -36,6 +38,7 @@ main(int argc, char *argv[])
if(setsid() < 0) if(setsid() < 0)
eprintf("setsid:"); eprintf("setsid:");
execvp(argv[0], argv); execvp(argv[0], argv);
eprintf("execvp:"); savederrno = errno;
return (errno == ENOENT) ? 127 : 126; weprintf("execvp %s:", argv[0]);
return (savederrno == ENOENT) ? 127 : 126;
} }