Author: hrs
Date: Sat Dec 24 07:13:33 2016
New Revision: 310494
URL: https://svnweb.freebsd.org/changeset/base/310494

Log:
  - Remove unused code.
  - Use closefrom().

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==============================================================================
--- head/usr.sbin/syslogd/syslogd.c     Sat Dec 24 02:31:26 2016        
(r310493)
+++ head/usr.sbin/syslogd/syslogd.c     Sat Dec 24 07:13:33 2016        
(r310494)
@@ -357,7 +357,7 @@ static void usage(void);
 static int     validate(struct sockaddr *, const char *);
 static void    unmapped(struct sockaddr *);
 static void    wallmsg(struct filed *, struct iovec *, const int iovlen);
-static int     waitdaemon(int, int, int);
+static int     waitdaemon(int);
 static void    timedout(int);
 static void    increase_rcvbuf(int);
 
@@ -606,7 +606,7 @@ main(int argc, char *argv[])
        }
 
        if ((!Foreground) && (!Debug)) {
-               ppid = waitdaemon(0, 0, 30);
+               ppid = waitdaemon(30);
                if (ppid < 0) {
                        warn("could not become daemon");
                        pidfile_remove(pfh);
@@ -2311,7 +2311,7 @@ markit(void)
  * Set a timer so we don't hang forever if it wedges.
  */
 static int
-waitdaemon(int nochdir, int noclose, int maxwait)
+waitdaemon(int maxwait)
 {
        int fd;
        int status;
@@ -2343,15 +2343,12 @@ waitdaemon(int nochdir, int noclose, int
        if (setsid() == -1)
                return (-1);
 
-       if (!nochdir)
-               (void)chdir("/");
-
-       if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+       (void)chdir("/");
+       if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
                (void)dup2(fd, STDIN_FILENO);
                (void)dup2(fd, STDOUT_FILENO);
                (void)dup2(fd, STDERR_FILENO);
-               if (fd > 2)
-                       (void)close (fd);
+               closefrom(STDERR_FILENO + 1);
        }
        return (getppid());
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to