Make sure to report an error if chdir(/) fail.

This commit is contained in:
Petter Reinholdtsen 2014-02-07 13:45:06 +00:00
parent de1344feb8
commit 3f08c42b06

View File

@ -663,7 +663,9 @@ void coredump(void)
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
setrlimit(RLIMIT_CORE, &rlim);
chdir("/");
if (0 != chdir("/"))
initlog(L_VB, "unable to chdir to /: %s",
strerror(errno));
signal(SIGSEGV, SIG_DFL);
raise(SIGSEGV);
@ -2794,7 +2796,9 @@ int telinit(char *progname, int argc, char **argv)
}
/* Change to the root directory. */
chdir("/");
if (0 != chdir("/"))
initlog(L_VB, "unable to chdir to /: %s",
strerror(errno));
/* Open the fifo and write a command. */
/* Make sure we don't hang on opening /dev/initctl */