-/*
- * We send requests for session logging to another process for two reasons.
- * First, we don't want to block if the log files go away (e.g. because
- * one or more are on hard-mounted NFS systems whose server crashes).
- * Second, despite all the crud already contained in init, it still isn't
- * right that init should care about session logging record formats and files.
- * We could use explicit 'Unix' IPC for this, but let's try to be POSIX...
- */
-int
-start_logger()
-{
- static char *argv[] = { _PATH_SLOGGER, 0 };
- int fd, pfd[2];
- pid_t pid;
- sigset_t mask;
-
- if (pipe(pfd) == -1) {
- warning("session logging disabled: can't make pipe to %s: %m",
- argv[0]);
- return -1;
- }
- if ((pid = fork()) == -1) {
- emergency("session logging disabled: can't fork for %s: %m",
- argv[0]);
- return -1;
- }
-
- if (pid == 0) {
- close(pfd[1]);
- if (pfd[0] != 0) {
- dup2(pfd[0], 0);
- close(pfd[0]);
- }
- if ((fd = open(_PATH_DEVNULL, O_WRONLY)) != -1) {
- if (fd != 1)
- dup2(fd, 1);
- if (fd != 2)
- dup2(fd, 2);
- if (fd != 1 && fd != 2)
- close(fd);
- } else {
- /* paranoid */
- close(1);
- close(2);
- }
- sigemptyset(&mask);
- sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
- execv(argv[0], argv);
- stall("can't exec %s: %m", argv[0]);
- _exit(1);
- }
-
- close(pfd[0]);
- fcntl(pfd[1], F_SETFD, FD_CLOEXEC);
- fcntl(pfd[1], F_SETFL, O_NONBLOCK);
-
- return pfd[1];
-}
-